Naming conventions.

This commit is contained in:
Jeff Young 2020-11-16 00:04:55 +00:00
parent f21e308830
commit 7933935b4a
25 changed files with 654 additions and 651 deletions

View File

@ -33,11 +33,11 @@ WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style ) : long style ) :
WX_HTML_REPORT_PANEL_BASE( parent, id, pos, size, style ), WX_HTML_REPORT_PANEL_BASE( parent, id, pos, size, style ),
m_reporter( this ), m_reporter( this ),
m_severities( -1 ), m_severities( -1 ),
m_lazyUpdate( false ), m_lazyUpdate( false ),
m_PrintInfo( true ) m_printInfo( true )
{ {
syncCheckboxes(); syncCheckboxes();
m_htmlView->SetPage( addHeader( "" ) ); m_htmlView->SetPage( addHeader( "" ) );
@ -314,10 +314,10 @@ void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event )
{ {
wxFileName fn; wxFileName fn;
if( m_ReportFileName.empty() ) if( m_reportFileName.empty() )
fn = wxT( "./report.txt" ); fn = wxT( "./report.txt" );
else else
fn = m_ReportFileName; fn = m_reportFileName;
wxFileDialog dlg( this, _( "Save Report to File" ), fn.GetPath(), fn.GetFullName(), wxFileDialog dlg( this, _( "Save Report to File" ), fn.GetPath(), fn.GetFullName(),
TextFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); TextFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
@ -349,7 +349,7 @@ void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event )
ConvertSmartQuotesAndDashes( &s ); ConvertSmartQuotesAndDashes( &s );
f.Write( s ); f.Write( s );
} }
m_ReportFileName = fn.GetFullPath(); m_reportFileName = fn.GetFullPath();
f.Close(); f.Close();
} }
@ -387,19 +387,19 @@ int WX_HTML_REPORT_PANEL::GetVisibleSeverities()
void WX_HTML_REPORT_PANEL::SetFileName( wxString& aReportFileName ) void WX_HTML_REPORT_PANEL::SetFileName( wxString& aReportFileName )
{ {
m_ReportFileName = aReportFileName; m_reportFileName = aReportFileName;
} }
wxString& WX_HTML_REPORT_PANEL::GetFileName( void ) wxString& WX_HTML_REPORT_PANEL::GetFileName( void )
{ {
return ( m_ReportFileName ); return ( m_reportFileName );
} }
void WX_HTML_REPORT_PANEL::SetPrintInfo( bool aPrintInfo ) void WX_HTML_REPORT_PANEL::SetPrintInfo( bool aPrintInfo )
{ {
m_PrintInfo = aPrintInfo; m_printInfo = aPrintInfo;
} }

View File

@ -146,10 +146,10 @@ private:
bool m_lazyUpdate; bool m_lazyUpdate;
///> Print "Info:" at the front of Info messages (default) ///> Print "Info:" at the front of Info messages (default)
bool m_PrintInfo; bool m_printInfo;
///> Use this as the filename instead of /bin/report.txt (default) ///> Use this as the filename instead of /bin/report.txt (default)
wxString m_ReportFileName; wxString m_reportFileName;
}; };
#endif //__WX_HTML_REPORT_PANEL_H__ #endif //__WX_HTML_REPORT_PANEL_H__

View File

@ -152,23 +152,23 @@ void DXF_PLOTTER::SetUnits( DXF_UNITS aUnit )
void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ) double aScale, bool aMirror )
{ {
plotOffset = aOffset; m_plotOffset = aOffset;
plotScale = aScale; m_plotScale = aScale;
/* DXF paper is 'virtual' so there is no need of a paper size. /* DXF paper is 'virtual' so there is no need of a paper size.
Also this way we can handle the aux origin which can be useful Also this way we can handle the aux origin which can be useful
(for example when aligning to a mechanical drawing) */ (for example when aligning to a mechanical drawing) */
paperSize.x = 0; m_paperSize.x = 0;
paperSize.y = 0; m_paperSize.y = 0;
/* Like paper size DXF units are abstract too. Anyway there is a /* Like paper size DXF units are abstract too. Anyway there is a
* system variable (MEASUREMENT) which will be set to 0 to indicate * system variable (MEASUREMENT) which will be set to 0 to indicate
* english units */ * english units */
m_IUsPerDecimil = aIusPerDecimil; m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = 1.0 / aIusPerDecimil; // Gives a DXF in decimils m_iuPerDeviceUnit = 1.0 / aIusPerDecimil; // Gives a DXF in decimils
iuPerDeviceUnit *= GetUnitScaling(); // Get the scaling factor for the current units m_iuPerDeviceUnit *= GetUnitScaling(); // Get the scaling factor for the current units
m_plotMirror = false; // No mirroring on DXF m_plotMirror = false; // No mirroring on DXF
m_currentColor = COLOR4D::BLACK; m_currentColor = COLOR4D::BLACK;
} }
@ -177,12 +177,12 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
*/ */
bool DXF_PLOTTER::StartPlot() bool DXF_PLOTTER::StartPlot()
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
// DXF HEADER - Boilerplate // DXF HEADER - Boilerplate
// Defines the minimum for drawing i.e. the angle system and the // Defines the minimum for drawing i.e. the angle system and the
// 4 linetypes (CONTINUOUS, DOTDASH, DASHED and DOTTED) // 4 linetypes (CONTINUOUS, DOTDASH, DASHED and DOTTED)
fprintf( outputFile, fprintf( m_outputFile,
" 0\n" " 0\n"
"SECTION\n" "SECTION\n"
" 2\n" " 2\n"
@ -293,7 +293,7 @@ bool DXF_PLOTTER::StartPlot()
"-0.2\n" "-0.2\n"
" 0\n" " 0\n"
"ENDTAB\n", "ENDTAB\n",
GetMeasurementDirective() ); GetMeasurementDirective() );
// Text styles table // Text styles table
// Defines 4 text styles, one for each bold/italic combination // Defines 4 text styles, one for each bold/italic combination
@ -302,12 +302,12 @@ bool DXF_PLOTTER::StartPlot()
" 2\n" " 2\n"
"STYLE\n" "STYLE\n"
" 70\n" " 70\n"
"4\n", outputFile ); "4\n", m_outputFile );
static const char *style_name[4] = {"KICAD", "KICADB", "KICADI", "KICADBI"}; static const char *style_name[4] = {"KICAD", "KICADB", "KICADI", "KICADBI"};
for(int i = 0; i < 4; i++ ) for(int i = 0; i < 4; i++ )
{ {
fprintf( outputFile, fprintf( m_outputFile,
" 0\n" " 0\n"
"STYLE\n" "STYLE\n"
" 2\n" " 2\n"
@ -339,7 +339,7 @@ bool DXF_PLOTTER::StartPlot()
numLayers = static_cast<EDA_COLOR_T>( 1 ); numLayers = static_cast<EDA_COLOR_T>( 1 );
// Layer table - one layer per color // Layer table - one layer per color
fprintf( outputFile, fprintf( m_outputFile,
" 0\n" " 0\n"
"ENDTAB\n" "ENDTAB\n"
" 0\n" " 0\n"
@ -360,7 +360,7 @@ bool DXF_PLOTTER::StartPlot()
for( EDA_COLOR_T i = BLACK; i < numLayers; i = static_cast<EDA_COLOR_T>( int( i ) + 1 ) ) for( EDA_COLOR_T i = BLACK; i < numLayers; i = static_cast<EDA_COLOR_T>( int( i ) + 1 ) )
{ {
fprintf( outputFile, fprintf( m_outputFile,
" 0\n" " 0\n"
"LAYER\n" "LAYER\n"
" 2\n" " 2\n"
@ -382,7 +382,7 @@ bool DXF_PLOTTER::StartPlot()
" 0\n" " 0\n"
"SECTION\n" "SECTION\n"
" 2\n" " 2\n"
"ENTITIES\n", outputFile ); "ENTITIES\n", m_outputFile );
return true; return true;
} }
@ -390,15 +390,15 @@ bool DXF_PLOTTER::StartPlot()
bool DXF_PLOTTER::EndPlot() bool DXF_PLOTTER::EndPlot()
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
// DXF FOOTER // DXF FOOTER
fputs( " 0\n" fputs( " 0\n"
"ENDSEC\n" "ENDSEC\n"
" 0\n" " 0\n"
"EOF\n", outputFile ); "EOF\n", m_outputFile );
fclose( outputFile ); fclose( m_outputFile );
outputFile = NULL; m_outputFile = NULL;
return true; return true;
} }
@ -409,14 +409,16 @@ bool DXF_PLOTTER::EndPlot()
*/ */
void DXF_PLOTTER::SetColor( COLOR4D color ) void DXF_PLOTTER::SetColor( COLOR4D color )
{ {
if( ( colorMode ) if( ( m_colorMode )
|| ( color == COLOR4D::BLACK ) || ( color == COLOR4D::BLACK )
|| ( color == COLOR4D::WHITE ) ) || ( color == COLOR4D::WHITE ) )
{ {
m_currentColor = color; m_currentColor = color;
} }
else else
{
m_currentColor = COLOR4D::BLACK; m_currentColor = COLOR4D::BLACK;
}
} }
/** /**
@ -424,7 +426,7 @@ void DXF_PLOTTER::SetColor( COLOR4D color )
*/ */
void DXF_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill, int width ) void DXF_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill, int width )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
MoveTo( p1 ); MoveTo( p1 );
LineTo( wxPoint( p1.x, p2.y ) ); LineTo( wxPoint( p1.x, p2.y ) );
LineTo( wxPoint( p2.x, p2.y ) ); LineTo( wxPoint( p2.x, p2.y ) );
@ -441,7 +443,7 @@ void DXF_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill, in
*/ */
void DXF_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_TYPE fill, int width ) void DXF_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_TYPE fill, int width )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
double radius = userToDeviceSize( diameter / 2 ); double radius = userToDeviceSize( diameter / 2 );
DPOINT centre_dev = userToDeviceCoordinates( centre ); DPOINT centre_dev = userToDeviceCoordinates( centre );
if( radius > 0 ) if( radius > 0 )
@ -450,24 +452,24 @@ void DXF_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_TYPE fill, i
if( fill == FILL_TYPE::NO_FILL ) if( fill == FILL_TYPE::NO_FILL )
{ {
fprintf( outputFile, "0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n", fprintf( m_outputFile, "0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n",
TO_UTF8( cname ), TO_UTF8( cname ),
centre_dev.x, centre_dev.y, radius ); centre_dev.x, centre_dev.y, radius );
} }
if( fill == FILL_TYPE::FILLED_SHAPE ) if( fill == FILL_TYPE::FILLED_SHAPE )
{ {
double r = radius*0.5; double r = radius*0.5;
fprintf( outputFile, "0\nPOLYLINE\n"); fprintf( m_outputFile, "0\nPOLYLINE\n");
fprintf( outputFile, "8\n%s\n66\n1\n70\n1\n", TO_UTF8( cname )); fprintf( m_outputFile, "8\n%s\n66\n1\n70\n1\n", TO_UTF8( cname ));
fprintf( outputFile, "40\n%g\n41\n%g\n", radius, radius); fprintf( m_outputFile, "40\n%g\n41\n%g\n", radius, radius);
fprintf( outputFile, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname )); fprintf( m_outputFile, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname ));
fprintf( outputFile, "10\n%g\n 20\n%g\n42\n1.0\n", fprintf( m_outputFile, "10\n%g\n 20\n%g\n42\n1.0\n",
centre_dev.x-r, centre_dev.y ); centre_dev.x-r, centre_dev.y );
fprintf( outputFile, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname )); fprintf( m_outputFile, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname ));
fprintf( outputFile, "10\n%g\n 20\n%g\n42\n1.0\n", fprintf( m_outputFile, "10\n%g\n 20\n%g\n42\n1.0\n",
centre_dev.x+r, centre_dev.y ); centre_dev.x+r, centre_dev.y );
fprintf( outputFile, "0\nSEQEND\n"); fprintf( m_outputFile, "0\nSEQEND\n");
} }
} }
} }
@ -583,26 +585,27 @@ void DXF_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
void DXF_PLOTTER::PenTo( const wxPoint& pos, char plume ) void DXF_PLOTTER::PenTo( const wxPoint& pos, char plume )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
if( plume == 'Z' ) if( plume == 'Z' )
{ {
return; return;
} }
DPOINT pos_dev = userToDeviceCoordinates( pos ); DPOINT pos_dev = userToDeviceCoordinates( pos );
DPOINT pen_lastpos_dev = userToDeviceCoordinates( penLastpos ); DPOINT pen_lastpos_dev = userToDeviceCoordinates( m_penLastpos );
if( penLastpos != pos && plume == 'D' ) if( m_penLastpos != pos && plume == 'D' )
{ {
wxASSERT( m_currentLineType >= PLOT_DASH_TYPE::FIRST_TYPE wxASSERT( m_currentLineType >= PLOT_DASH_TYPE::FIRST_TYPE
&& m_currentLineType <= PLOT_DASH_TYPE::LAST_TYPE ); && m_currentLineType <= PLOT_DASH_TYPE::LAST_TYPE );
// DXF LINE // DXF LINE
wxString cname = getDXFColorName( m_currentColor ); wxString cname = getDXFColorName( m_currentColor );
const char* lname = getDXFLineType( static_cast<PLOT_DASH_TYPE>( m_currentLineType ) ); const char* lname = getDXFLineType( static_cast<PLOT_DASH_TYPE>( 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", fprintf( m_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, TO_UTF8( cname ), lname,
pen_lastpos_dev.x, pen_lastpos_dev.y, pos_dev.x, pos_dev.y ); pen_lastpos_dev.x, pen_lastpos_dev.y, pos_dev.x, pos_dev.y );
} }
penLastpos = pos; m_penLastpos = pos;
} }
@ -647,7 +650,7 @@ void DXF_PLOTTER::ThickSegment( const wxPoint& aStart, const wxPoint& aEnd, int
void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius, void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius,
FILL_TYPE fill, int width ) FILL_TYPE fill, int width )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
if( radius <= 0 ) if( radius <= 0 )
return; return;
@ -665,7 +668,7 @@ void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
// Emit a DXF ARC entity // Emit a DXF ARC entity
wxString cname = getDXFColorName( m_currentColor ); wxString cname = getDXFColorName( m_currentColor );
fprintf( outputFile, fprintf( m_outputFile,
"0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n", "0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n",
TO_UTF8( cname ), TO_UTF8( cname ),
centre_dev.x, centre_dev.y, radius_dev, centre_dev.x, centre_dev.y, radius_dev,
@ -678,7 +681,7 @@ void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
void DXF_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double orient, void DXF_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double orient,
OUTLINE_MODE trace_mode, void* aData ) OUTLINE_MODE trace_mode, void* aData )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
wxSize size( aSize ); wxSize size( aSize );
/* The chip is reduced to an oval tablet with size.y > size.x /* The chip is reduced to an oval tablet with size.y > size.x
@ -700,7 +703,7 @@ void DXF_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double
void DXF_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre, void DXF_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre,
OUTLINE_MODE trace_mode, void* aData ) OUTLINE_MODE trace_mode, void* aData )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
Circle( pos, diametre, FILL_TYPE::NO_FILL ); Circle( pos, diametre, FILL_TYPE::NO_FILL );
} }
@ -711,7 +714,7 @@ void DXF_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre,
void DXF_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& padsize, void DXF_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& padsize,
double orient, OUTLINE_MODE trace_mode, void* aData ) double orient, OUTLINE_MODE trace_mode, void* aData )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
wxSize size; wxSize size;
int ox, oy, fx, fy; int ox, oy, fx, fy;
@ -815,7 +818,7 @@ void DXF_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
void DXF_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners, void DXF_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
double aPadOrient, OUTLINE_MODE aTrace_Mode, void* aData ) double aPadOrient, OUTLINE_MODE aTrace_Mode, void* aData )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
wxPoint coord[4]; /* coord actual corners of a trapezoidal trace */ wxPoint coord[4]; /* coord actual corners of a trapezoidal trace */
for( int ii = 0; ii < 4; ii++ ) for( int ii = 0; ii < 4; ii++ )
@ -926,7 +929,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
// Position, size, rotation and alignment // Position, size, rotation and alignment
// The two alignment point usages is somewhat idiot (see the DXF ref) // The two alignment point usages is somewhat idiot (see the DXF ref)
// Anyway since we don't use the fit/aligned options, they're the same // Anyway since we don't use the fit/aligned options, they're the same
fprintf( outputFile, fprintf( m_outputFile,
" 0\n" " 0\n"
"TEXT\n" "TEXT\n"
" 7\n" " 7\n"
@ -957,13 +960,13 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
"%d\n", // V alignment "%d\n", // V alignment
aBold ? (aItalic ? "KICADBI" : "KICADB") aBold ? (aItalic ? "KICADBI" : "KICADB")
: (aItalic ? "KICADI" : "KICAD"), : (aItalic ? "KICADI" : "KICAD"),
TO_UTF8( cname ), TO_UTF8( cname ),
origin_dev.x, origin_dev.x, origin_dev.x, origin_dev.x,
origin_dev.y, origin_dev.y, origin_dev.y, origin_dev.y,
size_dev.y, fabs( size_dev.x / size_dev.y ), size_dev.y, fabs( size_dev.x / size_dev.y ),
aOrient / 10.0, aOrient / 10.0,
aItalic ? DXF_OBLIQUE_ANGLE : 0, aItalic ? DXF_OBLIQUE_ANGLE : 0,
size_dev.x < 0 ? 2 : 0, // X mirror flag size_dev.x < 0 ? 2 : 0, // X mirror flag
h_code, v_code ); h_code, v_code );
/* There are two issue in emitting the text: /* There are two issue in emitting the text:
@ -990,7 +993,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
bool overlining = false; bool overlining = false;
fputs( " 1\n", outputFile ); fputs( " 1\n", m_outputFile );
for( unsigned i = 0; i < aText.length(); i++ ) for( unsigned i = 0; i < aText.length(); i++ )
{ {
@ -1005,7 +1008,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
if( ch > 255 ) if( ch > 255 )
{ {
// I can't encode this... // I can't encode this...
putc( '?', outputFile ); putc( '?', m_outputFile );
} }
else else
{ {
@ -1027,15 +1030,15 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
else else
{ {
// Handle the overline toggle // Handle the overline toggle
fputs( overlining ? "%%o" : "%%O", outputFile ); fputs( overlining ? "%%o" : "%%O", m_outputFile );
overlining = !overlining; overlining = !overlining;
} }
} }
putc( ch, outputFile ); putc( ch, m_outputFile );
} }
} }
putc( '\n', outputFile ); putc( '\n', m_outputFile );
} }
} }

View File

@ -88,19 +88,19 @@ void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
{ {
wxASSERT( aMirror == false ); wxASSERT( aMirror == false );
m_plotMirror = false; m_plotMirror = false;
plotOffset = aOffset; m_plotOffset = aOffset;
wxASSERT( aScale == 1 ); // aScale parameter is not used in Gerber wxASSERT( aScale == 1 ); // aScale parameter is not used in Gerber
plotScale = 1; // Plot scale is *always* 1.0 m_plotScale = 1; // Plot scale is *always* 1.0
m_IUsPerDecimil = aIusPerDecimil; m_IUsPerDecimil = aIusPerDecimil;
// gives now a default value to iuPerDeviceUnit (because the units of the caller is now known) // gives now a default value to iuPerDeviceUnit (because the units of the caller is now known)
// which could be modified later by calling SetGerberCoordinatesFormat() // which could be modified later by calling SetGerberCoordinatesFormat()
iuPerDeviceUnit = pow( 10.0, m_gerberUnitFmt ) / ( m_IUsPerDecimil * 10000.0 ); m_iuPerDeviceUnit = pow( 10.0, m_gerberUnitFmt ) / ( m_IUsPerDecimil * 10000.0 );
// We don't handle the filmbox, and it's more useful to keep the // We don't handle the filmbox, and it's more useful to keep the
// origin at the origin // origin at the origin
paperSize.x = 0; m_paperSize.x = 0;
paperSize.y = 0; m_paperSize.y = 0;
} }
@ -109,26 +109,26 @@ void GERBER_PLOTTER::SetGerberCoordinatesFormat( int aResolution, bool aUseInche
m_gerberUnitInch = aUseInches; m_gerberUnitInch = aUseInches;
m_gerberUnitFmt = aResolution; m_gerberUnitFmt = aResolution;
iuPerDeviceUnit = pow( 10.0, m_gerberUnitFmt ) / ( m_IUsPerDecimil * 10000.0 ); m_iuPerDeviceUnit = pow( 10.0, m_gerberUnitFmt ) / ( m_IUsPerDecimil * 10000.0 );
if( ! m_gerberUnitInch ) if( ! m_gerberUnitInch )
iuPerDeviceUnit *= 25.4; // gerber output in mm m_iuPerDeviceUnit *= 25.4; // gerber output in mm
} }
void GERBER_PLOTTER::emitDcode( const DPOINT& pt, int dcode ) void GERBER_PLOTTER::emitDcode( const DPOINT& pt, int dcode )
{ {
fprintf( outputFile, "X%dY%dD%02d*\n", KiROUND( pt.x ), KiROUND( pt.y ), dcode ); fprintf( m_outputFile, "X%dY%dD%02d*\n", KiROUND( pt.x ), KiROUND( pt.y ), dcode );
} }
void GERBER_PLOTTER::ClearAllAttributes() void GERBER_PLOTTER::ClearAllAttributes()
{ {
// Remove all attributes from object attributes dictionary (TO. and TA commands) // Remove all attributes from object attributes dictionary (TO. and TA commands)
if( m_useX2format ) if( m_useX2format )
fputs( "%TD*%\n", outputFile ); fputs( "%TD*%\n", m_outputFile );
else else
fputs( "G04 #@! TD*\n", outputFile ); fputs( "G04 #@! TD*\n", m_outputFile );
m_objectAttributesDictionnary.clear(); m_objectAttributesDictionnary.clear();
} }
@ -142,9 +142,9 @@ void GERBER_PLOTTER::clearNetAttribute()
// Remove all net attributes from object attributes dictionary // Remove all net attributes from object attributes dictionary
if( m_useX2format ) if( m_useX2format )
fputs( "%TD*%\n", outputFile ); fputs( "%TD*%\n", m_outputFile );
else else
fputs( "G04 #@! TD*\n", outputFile ); fputs( "G04 #@! TD*\n", m_outputFile );
m_objectAttributesDictionnary.clear(); m_objectAttributesDictionnary.clear();
} }
@ -188,12 +188,12 @@ void GERBER_PLOTTER::formatNetAttribute( GBR_NETLIST_METADATA* aData )
clearNetAttribute(); clearNetAttribute();
if( !short_attribute_string.empty() ) if( !short_attribute_string.empty() )
fputs( short_attribute_string.c_str(), outputFile ); fputs( short_attribute_string.c_str(), m_outputFile );
if( m_useX2format && !aData->m_ExtraData.IsEmpty() ) if( m_useX2format && !aData->m_ExtraData.IsEmpty() )
{ {
std::string extra_data = TO_UTF8( aData->m_ExtraData ); std::string extra_data = TO_UTF8( aData->m_ExtraData );
fputs( extra_data.c_str(), outputFile ); fputs( extra_data.c_str(), m_outputFile );
} }
} }
@ -203,26 +203,26 @@ bool GERBER_PLOTTER::StartPlot()
m_hasApertureRoundRect = false; // true is at least one round rect aperture is in use m_hasApertureRoundRect = false; // true is at least one round rect aperture is in use
m_hasApertureRotOval = false; // true is at least one oval rotated aperture is in use m_hasApertureRotOval = false; // true is at least one oval rotated aperture is in use
m_hasApertureRotRect = false; // true is at least one rect. rotated aperture is in use m_hasApertureRotRect = false; // true is at least one rect. rotated aperture is in use
m_hasApertureOutline4P = false; // true is at least one rotated rect/trapezoid aperture is in use m_hasApertureOutline4P = false; // true is at least one rotated rect/trapezoid aperture is in use
m_hasApertureChamferedRect = false; // true is at least one chamfered rect is in use m_hasApertureChamferedRect = false; // true is at least one chamfered rect is in use
wxASSERT( outputFile ); wxASSERT( m_outputFile );
finalFile = outputFile; // the actual gerber file will be created later finalFile = m_outputFile; // the actual gerber file will be created later
// Create a temp file in system temp to avoid potential network share buffer issues for the final read and save // Create a temp file in system temp to avoid potential network share buffer issues for the final read and save
m_workFilename = wxFileName::CreateTempFileName( "" ); m_workFilename = wxFileName::CreateTempFileName( "" );
workFile = wxFopen( m_workFilename, wxT( "wt" )); workFile = wxFopen( m_workFilename, wxT( "wt" ));
outputFile = workFile; m_outputFile = workFile;
wxASSERT( outputFile ); wxASSERT( m_outputFile );
if( outputFile == NULL ) if( m_outputFile == NULL )
return false; return false;
for( unsigned ii = 0; ii < m_headerExtraLines.GetCount(); ii++ ) for( unsigned ii = 0; ii < m_headerExtraLines.GetCount(); ii++ )
{ {
if( ! m_headerExtraLines[ii].IsEmpty() ) if( ! m_headerExtraLines[ii].IsEmpty() )
fprintf( outputFile, "%s\n", TO_UTF8( m_headerExtraLines[ii] ) ); fprintf( m_outputFile, "%s\n", TO_UTF8( m_headerExtraLines[ii] ) );
} }
// Set coordinate format to 3.6 or 4.5 absolute, leading zero omitted // Set coordinate format to 3.6 or 4.5 absolute, leading zero omitted
@ -231,36 +231,36 @@ bool GERBER_PLOTTER::StartPlot()
// It is fixed here to 3 (inch) or 4 (mm), but is not actually used // It is fixed here to 3 (inch) or 4 (mm), but is not actually used
int leadingDigitCount = m_gerberUnitInch ? 3 : 4; int leadingDigitCount = m_gerberUnitInch ? 3 : 4;
fprintf( outputFile, "%%FSLAX%d%dY%d%d*%%\n", fprintf( m_outputFile, "%%FSLAX%d%dY%d%d*%%\n",
leadingDigitCount, m_gerberUnitFmt, leadingDigitCount, m_gerberUnitFmt,
leadingDigitCount, m_gerberUnitFmt ); leadingDigitCount, m_gerberUnitFmt );
fprintf( outputFile, fprintf( m_outputFile,
"G04 Gerber Fmt %d.%d, Leading zero omitted, Abs format (unit %s)*\n", "G04 Gerber Fmt %d.%d, Leading zero omitted, Abs format (unit %s)*\n",
leadingDigitCount, m_gerberUnitFmt, leadingDigitCount, m_gerberUnitFmt,
m_gerberUnitInch ? "inch" : "mm" ); m_gerberUnitInch ? "inch" : "mm" );
wxString Title = creator + wxT( " " ) + GetBuildVersion(); wxString Title = m_creator + wxT( " " ) + GetBuildVersion();
// In gerber files, ASCII7 chars only are allowed. // In gerber files, ASCII7 chars only are allowed.
// So use a ISO date format (using a space as separator between date and time), // So use a ISO date format (using a space as separator between date and time),
// not a localized date format // not a localized date format
wxDateTime date = wxDateTime::Now(); wxDateTime date = wxDateTime::Now();
fprintf( outputFile, "G04 Created by KiCad (%s) date %s*\n", fprintf( m_outputFile, "G04 Created by KiCad (%s) date %s*\n",
TO_UTF8( Title ), TO_UTF8( date.FormatISOCombined( ' ') ) ); TO_UTF8( Title ), TO_UTF8( date.FormatISOCombined( ' ') ) );
/* Mass parameter: unit = INCHES/MM */ /* Mass parameter: unit = INCHES/MM */
if( m_gerberUnitInch ) if( m_gerberUnitInch )
fputs( "%MOIN*%\n", outputFile ); fputs( "%MOIN*%\n", m_outputFile );
else else
fputs( "%MOMM*%\n", outputFile ); fputs( "%MOMM*%\n", m_outputFile );
// Be sure the usual dark polarity is selected: // Be sure the usual dark polarity is selected:
fputs( "%LPD*%\n", outputFile ); fputs( "%LPD*%\n", m_outputFile );
// Set initial interpolation mode: always G01 (linear): // Set initial interpolation mode: always G01 (linear):
fputs( "G01*\n", outputFile ); fputs( "G01*\n", m_outputFile );
// Add aperture list start point // Add aperture list start point
fputs( "G04 APERTURE LIST*\n", outputFile ); fputs( "G04 APERTURE LIST*\n", m_outputFile );
// Give a minimal value to the default pen size, used to plot items in sketch mode // Give a minimal value to the default pen size, used to plot items in sketch mode
if( m_renderSettings ) if( m_renderSettings )
@ -279,21 +279,21 @@ bool GERBER_PLOTTER::EndPlot()
char line[1024]; char line[1024];
wxString msg; wxString msg;
wxASSERT( outputFile ); wxASSERT( m_outputFile );
/* Outfile is actually a temporary file i.e. workFile */ /* Outfile is actually a temporary file i.e. workFile */
fputs( "M02*\n", outputFile ); fputs( "M02*\n", m_outputFile );
fflush( outputFile ); fflush( m_outputFile );
fclose( workFile ); fclose( workFile );
workFile = wxFopen( m_workFilename, wxT( "rt" )); workFile = wxFopen( m_workFilename, wxT( "rt" ));
wxASSERT( workFile ); wxASSERT( workFile );
outputFile = finalFile; m_outputFile = finalFile;
// Placement of apertures in RS274X // Placement of apertures in RS274X
while( fgets( line, 1024, workFile ) ) while( fgets( line, 1024, workFile ) )
{ {
fputs( line, outputFile ); fputs( line, m_outputFile );
char* substr = strtok( line, "\n\r" ); char* substr = strtok( line, "\n\r" );
@ -304,40 +304,40 @@ bool GERBER_PLOTTER::EndPlot()
m_hasApertureOutline4P || m_hasApertureRotRect || m_hasApertureOutline4P || m_hasApertureRotRect ||
m_hasApertureChamferedRect ) m_hasApertureChamferedRect )
{ {
fputs( "G04 Aperture macros list*\n", outputFile ); fputs( "G04 Aperture macros list*\n", m_outputFile );
if( m_hasApertureRoundRect ) if( m_hasApertureRoundRect )
fputs( APER_MACRO_ROUNDRECT_HEADER, outputFile ); fputs( APER_MACRO_ROUNDRECT_HEADER, m_outputFile );
if( m_hasApertureRotOval ) if( m_hasApertureRotOval )
fputs( APER_MACRO_SHAPE_OVAL_HEADER, outputFile ); fputs( APER_MACRO_SHAPE_OVAL_HEADER, m_outputFile );
if( m_hasApertureRotRect ) if( m_hasApertureRotRect )
fputs( APER_MACRO_ROT_RECT_HEADER, outputFile ); fputs( APER_MACRO_ROT_RECT_HEADER, m_outputFile );
if( m_hasApertureOutline4P ) if( m_hasApertureOutline4P )
fputs( APER_MACRO_OUTLINE4P_HEADER, outputFile ); fputs( APER_MACRO_OUTLINE4P_HEADER, m_outputFile );
if( m_hasApertureChamferedRect ) if( m_hasApertureChamferedRect )
{ {
fputs( APER_MACRO_OUTLINE5P_HEADER, outputFile ); fputs( APER_MACRO_OUTLINE5P_HEADER, m_outputFile );
fputs( APER_MACRO_OUTLINE6P_HEADER, outputFile ); fputs( APER_MACRO_OUTLINE6P_HEADER, m_outputFile );
fputs( APER_MACRO_OUTLINE7P_HEADER, outputFile ); fputs( APER_MACRO_OUTLINE7P_HEADER, m_outputFile );
fputs( APER_MACRO_OUTLINE8P_HEADER, outputFile ); fputs( APER_MACRO_OUTLINE8P_HEADER, m_outputFile );
} }
fputs( "G04 Aperture macros list end*\n", outputFile ); fputs( "G04 Aperture macros list end*\n", m_outputFile );
} }
writeApertureList(); writeApertureList();
fputs( "G04 APERTURE END LIST*\n", outputFile ); fputs( "G04 APERTURE END LIST*\n", m_outputFile );
} }
} }
fclose( workFile ); fclose( workFile );
fclose( finalFile ); fclose( finalFile );
::wxRemoveFile( m_workFilename ); ::wxRemoveFile( m_workFilename );
outputFile = 0; m_outputFile = 0;
return true; return true;
} }
@ -356,7 +356,7 @@ void GERBER_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData )
int aperture_attribute = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0; int aperture_attribute = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( wxSize( aWidth, aWidth ), 0, 0.0, APERTURE::AT_PLOTTING, aperture_attribute ); selectAperture( wxSize( aWidth, aWidth ), 0, 0.0, APERTURE::AT_PLOTTING, aperture_attribute );
currentPenWidth = aWidth; m_currentPenWidth = aWidth;
} }
@ -459,7 +459,7 @@ void GERBER_PLOTTER::selectAperture( const wxSize& aSize, int aRadius, double aR
// Pick an existing aperture or create a new one // Pick an existing aperture or create a new one
m_currentApertureIdx = GetOrCreateAperture( aSize, aRadius, aRotDegree, m_currentApertureIdx = GetOrCreateAperture( aSize, aRadius, aRotDegree,
aType, aApertureAttribute ); aType, aApertureAttribute );
fprintf( outputFile, "D%d*\n", m_apertures[m_currentApertureIdx].m_DCode ); fprintf( m_outputFile, "D%d*\n", m_apertures[m_currentApertureIdx].m_DCode );
} }
} }
@ -492,7 +492,7 @@ void GERBER_PLOTTER::selectAperture( const std::vector<wxPoint>& aCorners, doubl
// Pick an existing aperture or create a new one // Pick an existing aperture or create a new one
m_currentApertureIdx = GetOrCreateAperture( aCorners, aRotDegree, m_currentApertureIdx = GetOrCreateAperture( aCorners, aRotDegree,
aType, aApertureAttribute ); aType, aApertureAttribute );
fprintf( outputFile, "D%d*\n", m_apertures[m_currentApertureIdx].m_DCode ); fprintf( m_outputFile, "D%d*\n", m_apertures[m_currentApertureIdx].m_DCode );
} }
} }
@ -513,7 +513,7 @@ void GERBER_PLOTTER::selectAperture( int aDiameter, double aPolygonRotation,
void GERBER_PLOTTER::writeApertureList() void GERBER_PLOTTER::writeApertureList()
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
char cbuf[1024]; char cbuf[1024];
std::string buffer; std::string buffer;
@ -527,7 +527,7 @@ void GERBER_PLOTTER::writeApertureList()
{ {
// apertude sizes are in inch or mm, regardless the // apertude sizes are in inch or mm, regardless the
// coordinates format // coordinates format
double fscale = 0.0001 * plotScale / m_IUsPerDecimil; // inches double fscale = 0.0001 * m_plotScale / m_IUsPerDecimil; // inches
if(! m_gerberUnitInch ) if(! m_gerberUnitInch )
fscale *= 25.4; // size in mm fscale *= 25.4; // size in mm
@ -538,7 +538,7 @@ void GERBER_PLOTTER::writeApertureList()
{ {
fputs( GBR_APERTURE_METADATA::FormatAttribute( fputs( GBR_APERTURE_METADATA::FormatAttribute(
(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB) attribute, (GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB) attribute,
useX1StructuredComment ).c_str(), outputFile ); useX1StructuredComment ).c_str(), m_outputFile );
} }
sprintf( cbuf, "%%ADD%d", tool.m_DCode ); sprintf( cbuf, "%%ADD%d", tool.m_DCode );
@ -685,8 +685,8 @@ void GERBER_PLOTTER::writeApertureList()
case APERTURE::AM_FREE_POLYGON: case APERTURE::AM_FREE_POLYGON:
{ {
// Write aperture header // Write aperture header
fprintf( outputFile, "%%%s%d*\n", "AMFp", tool.m_DCode ); fprintf( m_outputFile, "%%%s%d*\n", "AMFp", tool.m_DCode );
fprintf( outputFile, "4,1,%d,", (int)tool.m_Corners.size() ); fprintf( m_outputFile, "4,1,%d,", (int)tool.m_Corners.size() );
for( size_t ii = 0; ii <= tool.m_Corners.size(); ii++ ) for( size_t ii = 0; ii <= tool.m_Corners.size(); ii++ )
{ {
@ -695,11 +695,11 @@ void GERBER_PLOTTER::writeApertureList()
if( ii >= tool.m_Corners.size() ) if( ii >= tool.m_Corners.size() )
jj = 0; jj = 0;
fprintf( outputFile, "%#f,%#f,", fprintf( m_outputFile, "%#f,%#f,",
tool.m_Corners[jj].x * fscale, -tool.m_Corners[jj].y * fscale ); tool.m_Corners[jj].x * fscale, -tool.m_Corners[jj].y * fscale );
} }
// output rotation parameter // output rotation parameter
fputs( "$1*%\n", outputFile ); fputs( "$1*%\n", m_outputFile );
// Create specialized macro // Create specialized macro
sprintf( cbuf, "%s%d,", "Fp", tool.m_DCode ); sprintf( cbuf, "%s%d,", "Fp", tool.m_DCode );
@ -712,7 +712,7 @@ void GERBER_PLOTTER::writeApertureList()
} }
buffer += cbuf; buffer += cbuf;
fputs( buffer.c_str(), outputFile ); fputs( buffer.c_str(), m_outputFile );
m_apertureAttribute = attribute; m_apertureAttribute = attribute;
@ -721,9 +721,9 @@ void GERBER_PLOTTER::writeApertureList()
if( attribute ) if( attribute )
{ {
if( m_useX2format ) if( m_useX2format )
fputs( "%TD*%\n", outputFile ); fputs( "%TD*%\n", m_outputFile );
else else
fputs( "G04 #@! TD*\n", outputFile ); fputs( "G04 #@! TD*\n", m_outputFile );
m_apertureAttribute = 0; m_apertureAttribute = 0;
} }
@ -734,7 +734,7 @@ void GERBER_PLOTTER::writeApertureList()
void GERBER_PLOTTER::PenTo( const wxPoint& aPos, char plume ) void GERBER_PLOTTER::PenTo( const wxPoint& aPos, char plume )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
DPOINT pos_dev = userToDeviceCoordinates( aPos ); DPOINT pos_dev = userToDeviceCoordinates( aPos );
switch( plume ) switch( plume )
@ -750,7 +750,7 @@ void GERBER_PLOTTER::PenTo( const wxPoint& aPos, char plume )
emitDcode( pos_dev, 1 ); emitDcode( pos_dev, 1 );
} }
penState = plume; m_penState = plume;
} }
@ -805,18 +805,18 @@ void GERBER_PLOTTER::plotArc( const wxPoint& aCenter, double aStAngle, double aE
DPOINT devEnd = userToDeviceCoordinates( end ); DPOINT devEnd = userToDeviceCoordinates( end );
DPOINT devCenter = userToDeviceCoordinates( aCenter ) - userToDeviceCoordinates( start ); DPOINT devCenter = userToDeviceCoordinates( aCenter ) - userToDeviceCoordinates( start );
fprintf( outputFile, "G75*\n" ); // Multiquadrant (360 degrees) mode fprintf( m_outputFile, "G75*\n" ); // Multiquadrant (360 degrees) mode
if( aStAngle < aEndAngle ) if( aStAngle < aEndAngle )
fprintf( outputFile, "G03*\n" ); // Active circular interpolation, CCW fprintf( m_outputFile, "G03*\n" ); // Active circular interpolation, CCW
else else
fprintf( outputFile, "G02*\n" ); // Active circular interpolation, CW fprintf( m_outputFile, "G02*\n" ); // Active circular interpolation, CW
fprintf( outputFile, "X%dY%dI%dJ%dD01*\n", fprintf( m_outputFile, "X%dY%dI%dJ%dD01*\n",
KiROUND( devEnd.x ), KiROUND( devEnd.y ), KiROUND( devEnd.x ), KiROUND( devEnd.y ),
KiROUND( devCenter.x ), KiROUND( devCenter.y ) ); KiROUND( devCenter.x ), KiROUND( devCenter.y ) );
fprintf( outputFile, "G01*\n" ); // Back to linear interpol (perhaps useless here). fprintf( m_outputFile, "G01*\n" ); // Back to linear interpol (perhaps useless here).
} }
@ -836,7 +836,7 @@ void GERBER_PLOTTER::PlotGerberRegion( const std::vector< wxPoint >& aCornerList
if( !attrib.empty() ) if( !attrib.empty() )
{ {
fputs( attrib.c_str(), outputFile ); fputs( attrib.c_str(), m_outputFile );
clearTA_AperFunction = true; clearTA_AperFunction = true;
} }
} }
@ -848,11 +848,11 @@ void GERBER_PLOTTER::PlotGerberRegion( const std::vector< wxPoint >& aCornerList
{ {
if( m_useX2format ) if( m_useX2format )
{ {
fputs( "%TD.AperFunction*%\n", outputFile ); fputs( "%TD.AperFunction*%\n", m_outputFile );
} }
else else
{ {
fputs( "G04 #@! TD.AperFunction*\n", outputFile ); fputs( "G04 #@! TD.AperFunction*\n", m_outputFile );
} }
} }
} }
@ -873,10 +873,10 @@ void GERBER_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList,
if( aFill != FILL_TYPE::NO_FILL ) if( aFill != FILL_TYPE::NO_FILL )
{ {
fputs( "G36*\n", outputFile ); fputs( "G36*\n", m_outputFile );
MoveTo( aCornerList[0] ); MoveTo( aCornerList[0] );
fputs( "G01*\n", outputFile ); // Set linear interpolation. fputs( "G01*\n", m_outputFile ); // Set linear interpolation.
for( unsigned ii = 1; ii < aCornerList.size(); ii++ ) for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
LineTo( aCornerList[ii] ); LineTo( aCornerList[ii] );
@ -885,7 +885,7 @@ void GERBER_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList,
if( aCornerList[0] != aCornerList[aCornerList.size()-1] ) if( aCornerList[0] != aCornerList[aCornerList.size()-1] )
FinishTo( aCornerList[0] ); FinishTo( aCornerList[0] );
fputs( "G37*\n", outputFile ); fputs( "G37*\n", m_outputFile );
} }
if( aWidth > 0 ) // Draw the polyline/polygon outline if( aWidth > 0 ) // Draw the polyline/polygon outline
@ -943,9 +943,9 @@ void GERBER_PLOTTER::ThickArc( const wxPoint& centre, double StAngle, double End
{ {
SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH ); SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH );
Arc( centre, StAngle, EndAngle, Arc( centre, StAngle, EndAngle,
radius - ( width - currentPenWidth ) / 2, FILL_TYPE::NO_FILL, radius - ( width - m_currentPenWidth ) / 2, FILL_TYPE::NO_FILL,
DO_NOT_SET_LINE_WIDTH ); DO_NOT_SET_LINE_WIDTH );
Arc( centre, StAngle, EndAngle, radius + ( width - currentPenWidth ) / 2, FILL_TYPE::NO_FILL, Arc( centre, StAngle, EndAngle, radius + ( width - m_currentPenWidth ) / 2, FILL_TYPE::NO_FILL,
DO_NOT_SET_LINE_WIDTH ); DO_NOT_SET_LINE_WIDTH );
} }
} }
@ -965,15 +965,15 @@ void GERBER_PLOTTER::ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
else else
{ {
SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH ); SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH );
wxPoint offsetp1( p1.x - (width - currentPenWidth) / 2, wxPoint offsetp1( p1.x - (width - m_currentPenWidth) / 2,
p1.y - (width - currentPenWidth) / 2 ); p1.y - (width - m_currentPenWidth) / 2 );
wxPoint offsetp2( p2.x + (width - currentPenWidth) / 2, wxPoint offsetp2( p2.x + (width - m_currentPenWidth) / 2,
p2.y + (width - currentPenWidth) / 2 ); p2.y + (width - m_currentPenWidth) / 2 );
Rect( offsetp1, offsetp2, FILL_TYPE::NO_FILL, -1 ); Rect( offsetp1, offsetp2, FILL_TYPE::NO_FILL, -1 );
offsetp1.x += (width - currentPenWidth); offsetp1.x += (width - m_currentPenWidth);
offsetp1.y += (width - currentPenWidth); offsetp1.y += (width - m_currentPenWidth);
offsetp2.x -= (width - currentPenWidth); offsetp2.x -= (width - m_currentPenWidth);
offsetp2.y -= (width - currentPenWidth); offsetp2.y -= (width - m_currentPenWidth);
Rect( offsetp1, offsetp2, FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH ); Rect( offsetp1, offsetp2, FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH );
} }
} }
@ -993,9 +993,9 @@ void GERBER_PLOTTER::ThickCircle( const wxPoint& pos, int diametre, int width,
else else
{ {
SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH, gbr_metadata ); SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH, gbr_metadata );
Circle( pos, diametre - (width - currentPenWidth), Circle( pos, diametre - (width - m_currentPenWidth),
FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH ); FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH );
Circle( pos, diametre + (width - currentPenWidth), Circle( pos, diametre + (width - m_currentPenWidth),
FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH ); FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH );
} }
} }
@ -1038,7 +1038,7 @@ void GERBER_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre, OUTLINE_M
SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH ); SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH );
Circle( pos, diametre - currentPenWidth, FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH ); Circle( pos, diametre - m_currentPenWidth, FILL_TYPE::NO_FILL, DO_NOT_SET_LINE_WIDTH );
} }
else else
{ {
@ -1058,7 +1058,7 @@ void GERBER_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre, OUTLINE_M
void GERBER_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double orient, void GERBER_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double orient,
OUTLINE_MODE trace_mode, void* aData ) OUTLINE_MODE trace_mode, void* aData )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
wxSize size( aSize ); wxSize size( aSize );
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData ); GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
@ -1138,7 +1138,7 @@ void GERBER_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& aSize,
double orient, OUTLINE_MODE trace_mode, void* aData ) double orient, OUTLINE_MODE trace_mode, void* aData )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
wxSize size( aSize ); wxSize size( aSize );
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData ); GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
@ -1277,7 +1277,7 @@ void GERBER_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aS
if( !attrib.empty() ) if( !attrib.empty() )
{ {
fputs( attrib.c_str(), outputFile ); fputs( attrib.c_str(), m_outputFile );
clearTA_AperFunction = true; clearTA_AperFunction = true;
} }
} }
@ -1289,9 +1289,9 @@ void GERBER_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aS
if( clearTA_AperFunction ) if( clearTA_AperFunction )
{ {
if( m_useX2format ) if( m_useX2format )
fputs( "%TD.AperFunction*%\n", outputFile ); fputs( "%TD.AperFunction*%\n", m_outputFile );
else else
fputs( "G04 #@! TD.AperFunction*\n", outputFile ); fputs( "G04 #@! TD.AperFunction*\n", m_outputFile );
} }
} }
} }
@ -1403,8 +1403,8 @@ void GERBER_PLOTTER::plotRoundRectAsRegion( const wxPoint& aRectCenter, const wx
first_pt.x, first_pt.y, last_pt.x, last_pt.y ); first_pt.x, first_pt.y, last_pt.x, last_pt.y );
#endif #endif
fputs( "G36*\n", outputFile ); // Start region fputs( "G36*\n", m_outputFile ); // Start region
fputs( "G01*\n", outputFile ); // Set linear interpolation. fputs( "G01*\n", m_outputFile ); // Set linear interpolation.
first_pt = last_pt; first_pt = last_pt;
MoveTo( first_pt ); // Start point of region, must be same as end point MoveTo( first_pt ); // Start point of region, must be same as end point
@ -1421,7 +1421,7 @@ void GERBER_PLOTTER::plotRoundRectAsRegion( const wxPoint& aRectCenter, const wx
LineTo( rr_edge.m_end ); LineTo( rr_edge.m_end );
} }
fputs( "G37*\n", outputFile ); // Close region fputs( "G37*\n", m_outputFile ); // Close region
} }
@ -1711,7 +1711,7 @@ void GERBER_PLOTTER::Text( const wxPoint& aPos, const COLOR4D aColor,
void GERBER_PLOTTER::SetLayerPolarity( bool aPositive ) void GERBER_PLOTTER::SetLayerPolarity( bool aPositive )
{ {
if( aPositive ) if( aPositive )
fprintf( outputFile, "%%LPD*%%\n" ); fprintf( m_outputFile, "%%LPD*%%\n" );
else else
fprintf( outputFile, "%%LPC*%%\n" ); fprintf( m_outputFile, "%%LPC*%%\n" );
} }

View File

@ -224,15 +224,15 @@ HPGL_PLOTTER::HPGL_PLOTTER()
void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ) double aScale, bool aMirror )
{ {
plotOffset = aOffset; m_plotOffset = aOffset;
plotScale = aScale; m_plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil; m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = PLUsPERDECIMIL / aIusPerDecimil; m_iuPerDeviceUnit = PLUsPERDECIMIL / aIusPerDecimil;
/* Compute the paper size in IUs */ /* Compute the paper size in IUs */
paperSize = pageInfo.GetSizeMils(); m_paperSize = m_pageInfo.GetSizeMils();
paperSize.x *= 10.0 * aIusPerDecimil; m_paperSize.x *= 10.0 * aIusPerDecimil;
paperSize.y *= 10.0 * aIusPerDecimil; m_paperSize.y *= 10.0 * aIusPerDecimil;
m_plotMirror = aMirror; m_plotMirror = aMirror;
} }
@ -241,12 +241,12 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
*/ */
bool HPGL_PLOTTER::StartPlot() bool HPGL_PLOTTER::StartPlot()
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
fprintf( outputFile, "IN;VS%d;PU;PA;SP%d;\n", penSpeed, penNumber ); fprintf( m_outputFile, "IN;VS%d;PU;PA;SP%d;\n", penSpeed, penNumber );
// Set HPGL Pen Thickness (in mm) (usefull in polygon fill command) // Set HPGL Pen Thickness (in mm) (usefull in polygon fill command)
double penThicknessMM = userToDeviceSize( penDiameter )/40; double penThicknessMM = userToDeviceSize( penDiameter )/40;
fprintf( outputFile, "PT %.1f;\n", penThicknessMM ); fprintf( m_outputFile, "PT %.1f;\n", penThicknessMM );
return true; return true;
} }
@ -257,10 +257,10 @@ bool HPGL_PLOTTER::StartPlot()
*/ */
bool HPGL_PLOTTER::EndPlot() bool HPGL_PLOTTER::EndPlot()
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
fputs( "PU;PA;SP0;\n", outputFile ); fputs( "PU;PA;SP0;\n", m_outputFile );
fclose( outputFile ); fclose( m_outputFile );
outputFile = NULL; m_outputFile = NULL;
return true; return true;
} }
@ -275,10 +275,10 @@ void HPGL_PLOTTER::SetPenDiameter( double diameter )
*/ */
void HPGL_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill, int width ) void HPGL_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill, int width )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
DPOINT p2dev = userToDeviceCoordinates( p2 ); DPOINT p2dev = userToDeviceCoordinates( p2 );
MoveTo( p1 ); MoveTo( p1 );
fprintf( outputFile, "EA %.0f,%.0f;\n", p2dev.x, p2dev.y ); fprintf( m_outputFile, "EA %.0f,%.0f;\n", p2dev.x, p2dev.y );
PenFinish(); PenFinish();
} }
@ -287,7 +287,7 @@ void HPGL_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill, i
void HPGL_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_TYPE fill, void HPGL_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_TYPE fill,
int width ) int width )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
double radius = userToDeviceSize( diameter / 2 ); double radius = userToDeviceSize( diameter / 2 );
SetCurrentLineWidth( width ); SetCurrentLineWidth( width );
@ -295,15 +295,15 @@ void HPGL_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_TYPE fill,
{ {
// Draw the filled area // Draw the filled area
MoveTo( centre ); MoveTo( centre );
fprintf( outputFile, "PM 0; CI %g;\n", radius ); fprintf( m_outputFile, "PM 0; CI %g;\n", radius );
fprintf( outputFile, hpgl_end_polygon_cmd ); // Close, fill polygon and draw outlines fprintf( m_outputFile, hpgl_end_polygon_cmd ); // Close, fill polygon and draw outlines
PenFinish(); PenFinish();
} }
if( radius > 0 ) if( radius > 0 )
{ {
MoveTo( centre ); MoveTo( centre );
fprintf( outputFile, "CI %g;\n", radius ); fprintf( m_outputFile, "CI %g;\n", radius );
PenFinish(); PenFinish();
} }
} }
@ -326,7 +326,7 @@ void HPGL_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
{ {
// Draw the filled area // Draw the filled area
SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH ); SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH );
fprintf( outputFile, "PM 0;\n" ); // Start polygon fprintf( m_outputFile, "PM 0;\n" ); // Start polygon
for( unsigned ii = 1; ii < aCornerList.size(); ++ii ) for( unsigned ii = 1; ii < aCornerList.size(); ++ii )
LineTo( aCornerList[ii] ); LineTo( aCornerList[ii] );
@ -336,7 +336,7 @@ void HPGL_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
if( aCornerList[ii] != aCornerList[0] ) if( aCornerList[ii] != aCornerList[0] )
LineTo( aCornerList[0] ); LineTo( aCornerList[0] );
fprintf( outputFile, hpgl_end_polygon_cmd ); // Close, fill polygon and draw outlines fprintf( m_outputFile, hpgl_end_polygon_cmd ); // Close, fill polygon and draw outlines
} }
else else
{ {
@ -363,35 +363,35 @@ void HPGL_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
*/ */
void HPGL_PLOTTER::penControl( char plume ) void HPGL_PLOTTER::penControl( char plume )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
switch( plume ) switch( plume )
{ {
case 'U': case 'U':
if( penState != 'U' ) if( m_penState != 'U' )
{ {
fputs( "PU;", outputFile ); fputs( "PU;", m_outputFile );
penState = 'U'; m_penState = 'U';
} }
break; break;
case 'D': case 'D':
if( penState != 'D' ) if( m_penState != 'D' )
{ {
fputs( "PD;", outputFile ); fputs( "PD;", m_outputFile );
penState = 'D'; m_penState = 'D';
} }
break; break;
case 'Z': case 'Z':
fputs( "PU;", outputFile ); fputs( "PU;", m_outputFile );
penState = 'U'; m_penState = 'U';
penLastpos.x = -1; m_penLastpos.x = -1;
penLastpos.y = -1; m_penLastpos.y = -1;
break; break;
} }
} }
@ -399,7 +399,7 @@ void HPGL_PLOTTER::penControl( char plume )
void HPGL_PLOTTER::PenTo( const wxPoint& pos, char plume ) void HPGL_PLOTTER::PenTo( const wxPoint& pos, char plume )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
if( plume == 'Z' ) if( plume == 'Z' )
{ {
@ -410,10 +410,10 @@ void HPGL_PLOTTER::PenTo( const wxPoint& pos, char plume )
penControl( plume ); penControl( plume );
DPOINT pos_dev = userToDeviceCoordinates( pos ); DPOINT pos_dev = userToDeviceCoordinates( pos );
if( penLastpos != pos ) if( m_penLastpos != pos )
fprintf( outputFile, "PA %.0f,%.0f;\n", pos_dev.x, pos_dev.y ); fprintf( m_outputFile, "PA %.0f,%.0f;\n", pos_dev.x, pos_dev.y );
penLastpos = pos; m_penLastpos = pos;
} }
@ -422,21 +422,21 @@ void HPGL_PLOTTER::PenTo( const wxPoint& pos, char plume )
*/ */
void HPGL_PLOTTER::SetDash( PLOT_DASH_TYPE dashed ) void HPGL_PLOTTER::SetDash( PLOT_DASH_TYPE dashed )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
switch( dashed ) switch( dashed )
{ {
case PLOT_DASH_TYPE::DASH: case PLOT_DASH_TYPE::DASH:
fprintf( outputFile, "LT -2 4 1;\n" ); fprintf( m_outputFile, "LT -2 4 1;\n" );
break; break;
case PLOT_DASH_TYPE::DOT: case PLOT_DASH_TYPE::DOT:
fprintf( outputFile, "LT -1 2 1;\n" ); fprintf( m_outputFile, "LT -1 2 1;\n" );
break; break;
case PLOT_DASH_TYPE::DASHDOT: case PLOT_DASH_TYPE::DASHDOT:
fprintf( outputFile, "LT -4 6 1;\n" ); fprintf( m_outputFile, "LT -4 6 1;\n" );
break; break;
default: default:
fputs( "LT;\n", outputFile ); fputs( "LT;\n", m_outputFile );
} }
} }
@ -444,9 +444,7 @@ void HPGL_PLOTTER::SetDash( PLOT_DASH_TYPE dashed )
void HPGL_PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end, void HPGL_PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end,
int width, OUTLINE_MODE tracemode, void* aData ) int width, OUTLINE_MODE tracemode, void* aData )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
wxPoint center;
wxSize size;
// Suppress overlap if pen is too big // Suppress overlap if pen is too big
if( penDiameter >= width ) if( penDiameter >= width )
@ -455,7 +453,9 @@ void HPGL_PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end,
FinishTo( end ); FinishTo( end );
} }
else else
{
segmentAsOval( start, end, width, tracemode ); segmentAsOval( start, end, width, tracemode );
}
} }
@ -470,7 +470,7 @@ void HPGL_PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end,
void HPGL_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius, void HPGL_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius,
FILL_TYPE fill, int width ) FILL_TYPE fill, int width )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
double angle; double angle;
if( radius <= 0 ) if( radius <= 0 )
@ -492,12 +492,12 @@ void HPGL_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle,
cmap.y = centre.y - KiROUND( sindecideg( radius, StAngle ) ); cmap.y = centre.y - KiROUND( sindecideg( radius, StAngle ) );
DPOINT cmap_dev = userToDeviceCoordinates( cmap ); DPOINT cmap_dev = userToDeviceCoordinates( cmap );
fprintf( outputFile, fprintf( m_outputFile,
"PU;PA %.0f,%.0f;PD;AA %.0f,%.0f,", "PU;PA %.0f,%.0f;PD;AA %.0f,%.0f,",
cmap_dev.x, cmap_dev.y, cmap_dev.x, cmap_dev.y,
centre_dev.x, centre_dev.y ); centre_dev.x, centre_dev.y );
fprintf( outputFile, "%.0f", angle ); fprintf( m_outputFile, "%.0f", angle );
fprintf( outputFile, ";PU;\n" ); fprintf( m_outputFile, ";PU;\n" );
PenFinish(); PenFinish();
} }
@ -507,7 +507,7 @@ void HPGL_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle,
void HPGL_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double orient, void HPGL_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double orient,
OUTLINE_MODE trace_mode, void* aData ) OUTLINE_MODE trace_mode, void* aData )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
int deltaxy, cx, cy; int deltaxy, cx, cy;
wxSize size( aSize ); wxSize size( aSize );
@ -545,7 +545,7 @@ void HPGL_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double
void HPGL_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre, void HPGL_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre,
OUTLINE_MODE trace_mode, void* aData ) OUTLINE_MODE trace_mode, void* aData )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
DPOINT pos_dev = userToDeviceCoordinates( pos ); DPOINT pos_dev = userToDeviceCoordinates( pos );
int radius = diametre / 2; int radius = diametre / 2;
@ -568,14 +568,14 @@ void HPGL_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre,
// Gives a correct current starting point for the circle // Gives a correct current starting point for the circle
MoveTo( wxPoint( pos.x+radius, pos.y ) ); MoveTo( wxPoint( pos.x+radius, pos.y ) );
// Plot filled area and its outline // Plot filled area and its outline
fprintf( outputFile, "PM 0; PA %.0f,%.0f;CI %.0f;%s", fprintf( m_outputFile, "PM 0; PA %.0f,%.0f;CI %.0f;%s",
pos_dev.x, pos_dev.y, rsize, hpgl_end_polygon_cmd ); pos_dev.x, pos_dev.y, rsize, hpgl_end_polygon_cmd );
} }
else else
{ {
// Draw outline only: // Draw outline only:
fprintf( outputFile, "PA %.0f,%.0f;CI %.0f;\n", fprintf( m_outputFile, "PA %.0f,%.0f;CI %.0f;\n",
pos_dev.x, pos_dev.y, rsize ); pos_dev.x, pos_dev.y, rsize );
} }
PenFinish(); PenFinish();

View File

@ -105,14 +105,14 @@ std::string PDF_PLOTTER::encodeStringForPlotter( const wxString& aText )
bool PDF_PLOTTER::OpenFile( const wxString& aFullFilename ) bool PDF_PLOTTER::OpenFile( const wxString& aFullFilename )
{ {
filename = aFullFilename; m_filename = aFullFilename;
wxASSERT( !outputFile ); wxASSERT( !m_outputFile );
// Open the PDF file in binary mode // Open the PDF file in binary mode
outputFile = wxFopen( filename, wxT( "wb" ) ); m_outputFile = wxFopen( m_filename, wxT( "wb" ) );
if( outputFile == NULL ) if( m_outputFile == NULL )
return false ; return false ;
return true; return true;
@ -122,13 +122,13 @@ bool PDF_PLOTTER::OpenFile( const wxString& aFullFilename )
void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ) double aScale, bool aMirror )
{ {
m_plotMirror = aMirror; m_plotMirror = aMirror;
plotOffset = aOffset; m_plotOffset = aOffset;
plotScale = aScale; m_plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil; m_IUsPerDecimil = aIusPerDecimil;
// The CTM is set to 1 user unit per decimal // The CTM is set to 1 user unit per decimal
iuPerDeviceUnit = 1.0 / aIusPerDecimil; m_iuPerDeviceUnit = 1.0 / aIusPerDecimil;
/* The paper size in this engine is handled page by page /* The paper size in this engine is handled page by page
Look in the StartPage function */ Look in the StartPage function */
@ -149,10 +149,10 @@ void PDF_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData )
wxASSERT_MSG( aWidth > 0, "Plotter called to set negative pen width" ); wxASSERT_MSG( aWidth > 0, "Plotter called to set negative pen width" );
if( aWidth != currentPenWidth ) if( aWidth != m_currentPenWidth )
fprintf( workFile, "%g w\n", userToDeviceSize( aWidth ) ); fprintf( workFile, "%g w\n", userToDeviceSize( aWidth ) );
currentPenWidth = aWidth; m_currentPenWidth = aWidth;
} }
@ -336,18 +336,18 @@ void PDF_PLOTTER::PenTo( const wxPoint& pos, char plume )
if( plume == 'Z' ) if( plume == 'Z' )
{ {
if( penState != 'Z' ) if( m_penState != 'Z' )
{ {
fputs( "S\n", workFile ); fputs( "S\n", workFile );
penState = 'Z'; m_penState = 'Z';
penLastpos.x = -1; m_penLastpos.x = -1;
penLastpos.y = -1; m_penLastpos.y = -1;
} }
return; return;
} }
if( penState != plume || pos != penLastpos ) if( m_penState != plume || pos != m_penLastpos )
{ {
DPOINT pos_dev = userToDeviceCoordinates( pos ); DPOINT pos_dev = userToDeviceCoordinates( pos );
fprintf( workFile, "%g %g %c\n", fprintf( workFile, "%g %g %c\n",
@ -355,8 +355,8 @@ void PDF_PLOTTER::PenTo( const wxPoint& pos, char plume )
( plume=='D' ) ? 'l' : 'm' ); ( plume=='D' ) ? 'l' : 'm' );
} }
penState = plume; m_penState = plume;
penLastpos = pos; m_penLastpos = pos;
} }
@ -401,7 +401,7 @@ void PDF_PLOTTER::PlotImage( const wxImage & aImage, const wxPoint& aPos,
" /CS %s\n" " /CS %s\n"
" /W %d\n" " /W %d\n"
" /H %d\n" " /H %d\n"
"ID\n", colorMode ? "/RGB" : "/G", pix_size.x, pix_size.y ); "ID\n", m_colorMode ? "/RGB" : "/G", pix_size.x, pix_size.y );
/* Here comes the stream (in binary!). I *could* have hex or ascii84 /* Here comes the stream (in binary!). I *could* have hex or ascii84
encoded it, but who cares? I'll go through zlib anyway */ encoded it, but who cares? I'll go through zlib anyway */
@ -439,7 +439,7 @@ void PDF_PLOTTER::PlotImage( const wxImage & aImage, const wxPoint& aPos,
} }
// As usual these days, stdio buffering has to suffeeeeerrrr // As usual these days, stdio buffering has to suffeeeeerrrr
if( colorMode ) if( m_colorMode )
{ {
putc( r, workFile ); putc( r, workFile );
putc( g, workFile ); putc( g, workFile );
@ -467,29 +467,29 @@ int PDF_PLOTTER::allocPdfObject()
int PDF_PLOTTER::startPdfObject(int handle) int PDF_PLOTTER::startPdfObject(int handle)
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
wxASSERT( !workFile ); wxASSERT( !workFile );
if( handle < 0) if( handle < 0)
handle = allocPdfObject(); handle = allocPdfObject();
xrefTable[handle] = ftell( outputFile ); xrefTable[handle] = ftell( m_outputFile );
fprintf( outputFile, "%d 0 obj\n", handle ); fprintf( m_outputFile, "%d 0 obj\n", handle );
return handle; return handle;
} }
void PDF_PLOTTER::closePdfObject() void PDF_PLOTTER::closePdfObject()
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
wxASSERT( !workFile ); wxASSERT( !workFile );
fputs( "endobj\n", outputFile ); fputs( "endobj\n", m_outputFile );
} }
int PDF_PLOTTER::startPdfStream( int handle ) int PDF_PLOTTER::startPdfStream( int handle )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
wxASSERT( !workFile ); wxASSERT( !workFile );
handle = startPdfObject( handle ); handle = startPdfObject( handle );
@ -499,13 +499,13 @@ int PDF_PLOTTER::startPdfStream( int handle )
if( ADVANCED_CFG::GetCfg().m_DebugPDFWriter ) if( ADVANCED_CFG::GetCfg().m_DebugPDFWriter )
{ {
fprintf( outputFile, fprintf( m_outputFile,
"<< /Length %d 0 R >>\n" // Length is deferred "<< /Length %d 0 R >>\n" // Length is deferred
"stream\n", handle + 1 ); "stream\n", handle + 1 );
} }
else else
{ {
fprintf( outputFile, fprintf( m_outputFile,
"<< /Length %d 0 R /Filter /FlateDecode >>\n" // Length is deferred "<< /Length %d 0 R /Filter /FlateDecode >>\n" // Length is deferred
"stream\n", handle + 1 ); "stream\n", handle + 1 );
} }
@ -548,7 +548,7 @@ void PDF_PLOTTER::closePdfStream()
if( ADVANCED_CFG::GetCfg().m_DebugPDFWriter ) if( ADVANCED_CFG::GetCfg().m_DebugPDFWriter )
{ {
out_count = stream_len; out_count = stream_len;
fwrite( inbuf, out_count, 1, outputFile ); fwrite( inbuf, out_count, 1, m_outputFile );
} }
else else
{ {
@ -571,29 +571,29 @@ void PDF_PLOTTER::closePdfStream()
wxStreamBuffer* sb = memos.GetOutputStreamBuffer(); wxStreamBuffer* sb = memos.GetOutputStreamBuffer();
out_count = sb->Tell(); out_count = sb->Tell();
fwrite( sb->GetBufferStart(), 1, out_count, outputFile ); fwrite( sb->GetBufferStart(), 1, out_count, m_outputFile );
} }
delete[] inbuf; delete[] inbuf;
fputs( "endstream\n", outputFile ); fputs( "endstream\n", m_outputFile );
closePdfObject(); closePdfObject();
// Writing the deferred length as an indirect object // Writing the deferred length as an indirect object
startPdfObject( streamLengthHandle ); startPdfObject( streamLengthHandle );
fprintf( outputFile, "%u\n", out_count ); fprintf( m_outputFile, "%u\n", out_count );
closePdfObject(); closePdfObject();
} }
void PDF_PLOTTER::StartPage() void PDF_PLOTTER::StartPage()
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
wxASSERT( !workFile ); wxASSERT( !workFile );
// Compute the paper size in IUs // Compute the paper size in IUs
paperSize = pageInfo.GetSizeMils(); m_paperSize = m_pageInfo.GetSizeMils();
paperSize.x *= 10.0 / iuPerDeviceUnit; m_paperSize.x *= 10.0 / m_iuPerDeviceUnit;
paperSize.y *= 10.0 / iuPerDeviceUnit; m_paperSize.y *= 10.0 / m_iuPerDeviceUnit;
// Open the content stream; the page object will go later // Open the content stream; the page object will go later
pageStreamHandle = startPdfStream(); pageStreamHandle = startPdfStream();
@ -626,9 +626,9 @@ void PDF_PLOTTER::ClosePage()
to use */ to use */
const double BIGPTsPERMIL = 0.072; const double BIGPTsPERMIL = 0.072;
wxSize psPaperSize = pageInfo.GetSizeMils(); wxSize psPaperSize = m_pageInfo.GetSizeMils();
fprintf( outputFile, fprintf( m_outputFile,
"<<\n" "<<\n"
"/Type /Page\n" "/Type /Page\n"
"/Parent %d 0 R\n" "/Parent %d 0 R\n"
@ -652,7 +652,7 @@ void PDF_PLOTTER::ClosePage()
bool PDF_PLOTTER::StartPlot() bool PDF_PLOTTER::StartPlot()
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
// First things first: the customary null object // First things first: the customary null object
xrefTable.clear(); xrefTable.clear();
@ -661,7 +661,7 @@ bool PDF_PLOTTER::StartPlot()
/* The header (that's easy!). The second line is binary junk required /* The header (that's easy!). The second line is binary junk required
to make the file binary from the beginning (the important thing is to make the file binary from the beginning (the important thing is
that they must have the bit 7 set) */ that they must have the bit 7 set) */
fputs( "%PDF-1.5\n%\200\201\202\203\n", outputFile ); fputs( "%PDF-1.5\n%\200\201\202\203\n", m_outputFile );
/* Allocate an entry for the page tree root, it will go in every page /* Allocate an entry for the page tree root, it will go in every page
parent entry */ parent entry */
@ -681,7 +681,7 @@ bool PDF_PLOTTER::StartPlot()
bool PDF_PLOTTER::EndPlot() bool PDF_PLOTTER::EndPlot()
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
// Close the current page (often the only one) // Close the current page (often the only one)
ClosePage(); ClosePage();
@ -706,7 +706,7 @@ bool PDF_PLOTTER::EndPlot()
for( int i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
fontdefs[i].font_handle = startPdfObject(); fontdefs[i].font_handle = startPdfObject();
fprintf( outputFile, fprintf( m_outputFile,
"<< /BaseFont %s\n" "<< /BaseFont %s\n"
" /Type /Font\n" " /Type /Font\n"
" /Subtype /Type1\n" " /Subtype /Type1\n"
@ -721,15 +721,15 @@ bool PDF_PLOTTER::EndPlot()
// Named font dictionary (was allocated, now we emit it) // Named font dictionary (was allocated, now we emit it)
startPdfObject( fontResDictHandle ); startPdfObject( fontResDictHandle );
fputs( "<<\n", outputFile ); fputs( "<<\n", m_outputFile );
for( int i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
fprintf( outputFile, " %s %d 0 R\n", fprintf( m_outputFile, " %s %d 0 R\n",
fontdefs[i].rsname, fontdefs[i].font_handle ); fontdefs[i].rsname, fontdefs[i].font_handle );
} }
fputs( ">>\n", outputFile ); fputs( ">>\n", m_outputFile );
closePdfObject(); closePdfObject();
/* The page tree: it's a B-tree but luckily we only have few pages! /* The page tree: it's a B-tree but luckily we only have few pages!
@ -738,12 +738,12 @@ bool PDF_PLOTTER::EndPlot()
startPdfObject( pageTreeHandle ); startPdfObject( pageTreeHandle );
fputs( "<<\n" fputs( "<<\n"
"/Type /Pages\n" "/Type /Pages\n"
"/Kids [\n", outputFile ); "/Kids [\n", m_outputFile );
for( unsigned i = 0; i < pageHandles.size(); i++ ) for( unsigned i = 0; i < pageHandles.size(); i++ )
fprintf( outputFile, "%d 0 R\n", pageHandles[i] ); fprintf( m_outputFile, "%d 0 R\n", pageHandles[i] );
fprintf( outputFile, fprintf( m_outputFile,
"]\n" "]\n"
"/Count %ld\n" "/Count %ld\n"
">>\n", (long) pageHandles.size() ); ">>\n", (long) pageHandles.size() );
@ -757,14 +757,14 @@ bool PDF_PLOTTER::EndPlot()
strftime( date_buf, 250, "D:%Y%m%d%H%M%S", strftime( date_buf, 250, "D:%Y%m%d%H%M%S",
localtime( &ltime ) ); localtime( &ltime ) );
if( title.IsEmpty() ) if( m_title.IsEmpty() )
{ {
// Windows uses '\' and other platforms ue '/' as separator // Windows uses '\' and other platforms ue '/' as separator
title = filename.AfterLast('\\'); m_title = m_filename.AfterLast( '\\');
title = title.AfterLast('/'); m_title = m_title.AfterLast( '/');
} }
fprintf( outputFile, fprintf( m_outputFile,
"<<\n" "<<\n"
"/Producer (KiCad PDF)\n" "/Producer (KiCad PDF)\n"
"/CreationDate (%s)\n" "/CreationDate (%s)\n"
@ -772,15 +772,15 @@ bool PDF_PLOTTER::EndPlot()
"/Title %s\n" "/Title %s\n"
"/Trapped False\n", "/Trapped False\n",
date_buf, date_buf,
encodeStringForPlotter( creator ).c_str(), encodeStringForPlotter( m_creator ).c_str(),
encodeStringForPlotter( title ).c_str() ); encodeStringForPlotter( m_title ).c_str() );
fputs( ">>\n", outputFile ); fputs( ">>\n", m_outputFile );
closePdfObject(); closePdfObject();
// The catalog, at last // The catalog, at last
int catalogHandle = startPdfObject(); int catalogHandle = startPdfObject();
fprintf( outputFile, fprintf( m_outputFile,
"<<\n" "<<\n"
"/Type /Catalog\n" "/Type /Catalog\n"
"/Pages %d 0 R\n" "/Pages %d 0 R\n"
@ -793,19 +793,19 @@ bool PDF_PLOTTER::EndPlot()
/* Emit the xref table (format is crucial to the byte, each entry must /* Emit the xref table (format is crucial to the byte, each entry must
be 20 bytes long, and object zero must be done in that way). Also be 20 bytes long, and object zero must be done in that way). Also
the offset must be kept along for the trailer */ the offset must be kept along for the trailer */
long xref_start = ftell( outputFile ); long xref_start = ftell( m_outputFile );
fprintf( outputFile, fprintf( m_outputFile,
"xref\n" "xref\n"
"0 %ld\n" "0 %ld\n"
"0000000000 65535 f \n", (long) xrefTable.size() ); "0000000000 65535 f \n", (long) xrefTable.size() );
for( unsigned i = 1; i < xrefTable.size(); i++ ) for( unsigned i = 1; i < xrefTable.size(); i++ )
{ {
fprintf( outputFile, "%010ld 00000 n \n", xrefTable[i] ); fprintf( m_outputFile, "%010ld 00000 n \n", xrefTable[i] );
} }
// Done the xref, go for the trailer // Done the xref, go for the trailer
fprintf( outputFile, fprintf( m_outputFile,
"trailer\n" "trailer\n"
"<< /Size %lu /Root %d 0 R /Info %d 0 R >>\n" "<< /Size %lu /Root %d 0 R /Info %d 0 R >>\n"
"startxref\n" "startxref\n"
@ -813,8 +813,8 @@ bool PDF_PLOTTER::EndPlot()
"%%%%EOF\n", "%%%%EOF\n",
(unsigned long) xrefTable.size(), catalogHandle, infoDictHandle, xref_start ); (unsigned long) xrefTable.size(), catalogHandle, infoDictHandle, xref_start );
fclose( outputFile ); fclose( m_outputFile );
outputFile = NULL; m_outputFile = NULL;
return true; return true;
} }

View File

@ -64,9 +64,9 @@ static int getFillId( FILL_TYPE aFill )
void PSLIKE_PLOTTER::SetColor( COLOR4D color ) void PSLIKE_PLOTTER::SetColor( COLOR4D color )
{ {
if( colorMode ) if( m_colorMode )
{ {
if( negativeMode ) if( m_negativeMode )
emitSetRGBColor( 1 - color.r, 1 - color.g, 1 - color.b ); emitSetRGBColor( 1 - color.r, 1 - color.g, 1 - color.b );
else else
emitSetRGBColor( color.r, color.g, color.b ); emitSetRGBColor( color.r, color.g, color.b );
@ -80,7 +80,7 @@ void PSLIKE_PLOTTER::SetColor( COLOR4D color )
double k = 1; // White double k = 1; // White
if( color != COLOR4D::WHITE ) if( color != COLOR4D::WHITE )
k = 0; k = 0;
if( negativeMode ) if( m_negativeMode )
emitSetRGBColor( 1 - k, 1 - k, 1 - k ); emitSetRGBColor( 1 - k, 1 - k, 1 - k );
else else
emitSetRGBColor( k, k, k ); emitSetRGBColor( k, k, k );
@ -91,7 +91,7 @@ void PSLIKE_PLOTTER::SetColor( COLOR4D color )
void PSLIKE_PLOTTER::FlashPadOval( const wxPoint& aPadPos, const wxSize& aSize, void PSLIKE_PLOTTER::FlashPadOval( const wxPoint& aPadPos, const wxSize& aSize,
double aPadOrient, OUTLINE_MODE aTraceMode, void* aData ) double aPadOrient, OUTLINE_MODE aTraceMode, void* aData )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
int x0, y0, x1, y1, delta; int x0, y0, x1, y1, delta;
wxSize size( aSize ); wxSize size( aSize );
@ -420,16 +420,16 @@ void PSLIKE_PLOTTER::postscriptOverlinePositions( const wxString& aText, int aXS
void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ) double aScale, bool aMirror )
{ {
wxASSERT( !outputFile ); wxASSERT( !m_outputFile );
m_plotMirror = aMirror; m_plotMirror = aMirror;
plotOffset = aOffset; m_plotOffset = aOffset;
plotScale = aScale; m_plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil; m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = 1.0 / aIusPerDecimil; m_iuPerDeviceUnit = 1.0 / aIusPerDecimil;
/* Compute the paper size in IUs */ /* Compute the paper size in IUs */
paperSize = pageInfo.GetSizeMils(); m_paperSize = m_pageInfo.GetSizeMils();
paperSize.x *= 10.0 * aIusPerDecimil; m_paperSize.x *= 10.0 * aIusPerDecimil;
paperSize.y *= 10.0 * aIusPerDecimil; m_paperSize.y *= 10.0 * aIusPerDecimil;
} }
@ -534,7 +534,7 @@ void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
*/ */
void PS_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData ) void PS_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
if( aWidth == DO_NOT_SET_LINE_WIDTH ) if( aWidth == DO_NOT_SET_LINE_WIDTH )
return; return;
@ -546,18 +546,18 @@ void PS_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData )
wxASSERT_MSG( aWidth > 0, "Plotter called to set negative pen width" ); wxASSERT_MSG( aWidth > 0, "Plotter called to set negative pen width" );
if( aWidth != GetCurrentLineWidth() ) if( aWidth != GetCurrentLineWidth() )
fprintf( outputFile, "%g setlinewidth\n", userToDeviceSize( aWidth ) ); fprintf( m_outputFile, "%g setlinewidth\n", userToDeviceSize( aWidth ) );
currentPenWidth = aWidth; m_currentPenWidth = aWidth;
} }
void PS_PLOTTER::emitSetRGBColor( double r, double g, double b ) void PS_PLOTTER::emitSetRGBColor( double r, double g, double b )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
// XXX why %.3g ? shouldn't %g suffice? who cares... // XXX why %.3g ? shouldn't %g suffice? who cares...
fprintf( outputFile, "%.3g %.3g %.3g setrgbcolor\n", r, g, b ); fprintf( m_outputFile, "%.3g %.3g %.3g setrgbcolor\n", r, g, b );
} }
@ -569,20 +569,20 @@ void PS_PLOTTER::SetDash( PLOT_DASH_TYPE dashed )
switch( dashed ) switch( dashed )
{ {
case PLOT_DASH_TYPE::DASH: case PLOT_DASH_TYPE::DASH:
fprintf( outputFile, "[%d %d] 0 setdash\n", fprintf( m_outputFile, "[%d %d] 0 setdash\n",
(int) GetDashMarkLenIU(), (int) GetDashGapLenIU() ); (int) GetDashMarkLenIU(), (int) GetDashGapLenIU() );
break; break;
case PLOT_DASH_TYPE::DOT: case PLOT_DASH_TYPE::DOT:
fprintf( outputFile, "[%d %d] 0 setdash\n", fprintf( m_outputFile, "[%d %d] 0 setdash\n",
(int) GetDotMarkLenIU(), (int) GetDashGapLenIU() ); (int) GetDotMarkLenIU(), (int) GetDashGapLenIU() );
break; break;
case PLOT_DASH_TYPE::DASHDOT: case PLOT_DASH_TYPE::DASHDOT:
fprintf( outputFile, "[%d %d %d %d] 0 setdash\n", fprintf( m_outputFile, "[%d %d %d %d] 0 setdash\n",
(int) GetDashMarkLenIU(), (int) GetDashGapLenIU(), (int) GetDashMarkLenIU(), (int) GetDashGapLenIU(),
(int) GetDotMarkLenIU(), (int) GetDashGapLenIU() ); (int) GetDotMarkLenIU(), (int) GetDashGapLenIU() );
break; break;
default: default:
fputs( "solidline\n", outputFile ); fputs( "solidline\n", m_outputFile );
} }
} }
@ -593,26 +593,26 @@ void PS_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill, int
DPOINT p2_dev = userToDeviceCoordinates( p2 ); DPOINT p2_dev = userToDeviceCoordinates( p2 );
SetCurrentLineWidth( width ); SetCurrentLineWidth( width );
fprintf( outputFile, "%g %g %g %g rect%d\n", p1_dev.x, p1_dev.y, fprintf( m_outputFile, "%g %g %g %g rect%d\n", p1_dev.x, p1_dev.y,
p2_dev.x - p1_dev.x, p2_dev.y - p1_dev.y, getFillId( fill ) ); p2_dev.x - p1_dev.x, p2_dev.y - p1_dev.y, getFillId( fill ) );
} }
void PS_PLOTTER::Circle( const wxPoint& pos, int diametre, FILL_TYPE fill, int width ) void PS_PLOTTER::Circle( const wxPoint& pos, int diametre, FILL_TYPE fill, int width )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
DPOINT pos_dev = userToDeviceCoordinates( pos ); DPOINT pos_dev = userToDeviceCoordinates( pos );
double radius = userToDeviceSize( diametre / 2.0 ); double radius = userToDeviceSize( diametre / 2.0 );
SetCurrentLineWidth( width ); SetCurrentLineWidth( width );
fprintf( outputFile, "%g %g %g cir%d\n", pos_dev.x, pos_dev.y, radius, getFillId( fill ) ); fprintf( m_outputFile, "%g %g %g cir%d\n", pos_dev.x, pos_dev.y, radius, getFillId( fill ) );
} }
void PS_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, void PS_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle,
int radius, FILL_TYPE fill, int width ) int radius, FILL_TYPE fill, int width )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
if( radius <= 0 ) if( radius <= 0 )
return; return;
@ -641,7 +641,7 @@ void PS_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle,
} }
} }
fprintf( outputFile, "%g %g %g %g %g arc%d\n", centre_dev.x, centre_dev.y, fprintf( m_outputFile, "%g %g %g %g %g arc%d\n", centre_dev.x, centre_dev.y,
radius_dev, StAngle / 10.0, EndAngle / 10.0, getFillId( fill ) ); radius_dev, StAngle / 10.0, EndAngle / 10.0, getFillId( fill ) );
} }
@ -655,16 +655,16 @@ void PS_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList,
SetCurrentLineWidth( aWidth ); SetCurrentLineWidth( aWidth );
DPOINT pos = userToDeviceCoordinates( aCornerList[0] ); DPOINT pos = userToDeviceCoordinates( aCornerList[0] );
fprintf( outputFile, "newpath\n%g %g moveto\n", pos.x, pos.y ); fprintf( m_outputFile, "newpath\n%g %g moveto\n", pos.x, pos.y );
for( unsigned ii = 1; ii < aCornerList.size(); ii++ ) for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
{ {
pos = userToDeviceCoordinates( aCornerList[ii] ); pos = userToDeviceCoordinates( aCornerList[ii] );
fprintf( outputFile, "%g %g lineto\n", pos.x, pos.y ); fprintf( m_outputFile, "%g %g lineto\n", pos.x, pos.y );
} }
// Close/(fill) the path // Close/(fill) the path
fprintf( outputFile, "poly%d\n", getFillId( aFill ) ); fprintf( m_outputFile, "poly%d\n", getFillId( aFill ) );
} }
@ -690,28 +690,28 @@ void PS_PLOTTER::PlotImage( const wxImage & aImage, const wxPoint& aPos,
end.x = start.x + drawsize.x; end.x = start.x + drawsize.x;
end.y = start.y - drawsize.y; end.y = start.y - drawsize.y;
fprintf( outputFile, "/origstate save def\n" ); fprintf( m_outputFile, "/origstate save def\n" );
fprintf( outputFile, "/pix %d string def\n", pix_size.x ); fprintf( m_outputFile, "/pix %d string def\n", pix_size.x );
// Locate lower-left corner of image // Locate lower-left corner of image
DPOINT start_dev = userToDeviceCoordinates( start ); DPOINT start_dev = userToDeviceCoordinates( start );
fprintf( outputFile, "%g %g translate\n", start_dev.x, start_dev.y ); fprintf( m_outputFile, "%g %g translate\n", start_dev.x, start_dev.y );
// Map image size to device // Map image size to device
DPOINT end_dev = userToDeviceCoordinates( end ); DPOINT end_dev = userToDeviceCoordinates( end );
fprintf( outputFile, "%g %g scale\n", fprintf( m_outputFile, "%g %g scale\n",
std::abs(end_dev.x - start_dev.x), std::abs(end_dev.y - start_dev.y)); std::abs(end_dev.x - start_dev.x), std::abs(end_dev.y - start_dev.y));
// Dimensions of source image (in pixels // Dimensions of source image (in pixels
fprintf( outputFile, "%d %d 8", pix_size.x, pix_size.y ); fprintf( m_outputFile, "%d %d 8", pix_size.x, pix_size.y );
// Map unit square to source // Map unit square to source
fprintf( outputFile, " [%d 0 0 %d 0 %d]\n", pix_size.x, -pix_size.y , pix_size.y); fprintf( m_outputFile, " [%d 0 0 %d 0 %d]\n", pix_size.x, -pix_size.y , pix_size.y);
// include image data in ps file // include image data in ps file
fprintf( outputFile, "{currentfile pix readhexstring pop}\n" ); fprintf( m_outputFile, "{currentfile pix readhexstring pop}\n" );
if( colorMode ) if( m_colorMode )
fputs( "false 3 colorimage\n", outputFile ); fputs( "false 3 colorimage\n", m_outputFile );
else else
fputs( "image\n", outputFile ); fputs( "image\n", m_outputFile );
// Single data source, 3 colors, Output RGB data (hexadecimal) // Single data source, 3 colors, Output RGB data (hexadecimal)
// (or the same downscaled to gray) // (or the same downscaled to gray)
int jj = 0; int jj = 0;
@ -723,7 +723,7 @@ void PS_PLOTTER::PlotImage( const wxImage & aImage, const wxPoint& aPos,
if( jj >= 16 ) if( jj >= 16 )
{ {
jj = 0; jj = 0;
fprintf( outputFile, "\n"); fprintf( m_outputFile, "\n");
} }
int red, green, blue; int red, green, blue;
@ -756,55 +756,57 @@ void PS_PLOTTER::PlotImage( const wxImage & aImage, const wxPoint& aPos,
} }
} }
if( colorMode ) if( m_colorMode )
fprintf( outputFile, "%2.2X%2.2X%2.2X", red, green, blue ); {
fprintf( m_outputFile, "%2.2X%2.2X%2.2X", red, green, blue );
}
else else
{ {
// Greyscale conversion (CIE 1931) // Greyscale conversion (CIE 1931)
unsigned char grey = KiROUND( red * 0.2126 + green * 0.7152 + blue * 0.0722 ); unsigned char grey = KiROUND( red * 0.2126 + green * 0.7152 + blue * 0.0722 );
fprintf( outputFile, "%2.2X", grey ); fprintf( m_outputFile, "%2.2X", grey );
} }
} }
} }
fprintf( outputFile, "\n"); fprintf( m_outputFile, "\n");
fprintf( outputFile, "origstate restore\n" ); fprintf( m_outputFile, "origstate restore\n" );
} }
void PS_PLOTTER::PenTo( const wxPoint& pos, char plume ) void PS_PLOTTER::PenTo( const wxPoint& pos, char plume )
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
if( plume == 'Z' ) if( plume == 'Z' )
{ {
if( penState != 'Z' ) if( m_penState != 'Z' )
{ {
fputs( "stroke\n", outputFile ); fputs( "stroke\n", m_outputFile );
penState = 'Z'; m_penState = 'Z';
penLastpos.x = -1; m_penLastpos.x = -1;
penLastpos.y = -1; m_penLastpos.y = -1;
} }
return; return;
} }
if( penState == 'Z' ) if( m_penState == 'Z' )
{ {
fputs( "newpath\n", outputFile ); fputs( "newpath\n", m_outputFile );
} }
if( penState != plume || pos != penLastpos ) if( m_penState != plume || pos != m_penLastpos )
{ {
DPOINT pos_dev = userToDeviceCoordinates( pos ); DPOINT pos_dev = userToDeviceCoordinates( pos );
fprintf( outputFile, "%g %g %sto\n", fprintf( m_outputFile, "%g %g %sto\n",
pos_dev.x, pos_dev.y, pos_dev.x, pos_dev.y,
( plume=='D' ) ? "line" : "move" ); ( plume=='D' ) ? "line" : "move" );
} }
penState = plume; m_penState = plume;
penLastpos = pos; m_penLastpos = pos;
} }
@ -823,7 +825,7 @@ void PS_PLOTTER::PenTo( const wxPoint& pos, char plume )
*/ */
bool PS_PLOTTER::StartPlot() bool PS_PLOTTER::StartPlot()
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
wxString msg; wxString msg;
static const char* PSMacro[] = static const char* PSMacro[] =
@ -881,16 +883,16 @@ bool PS_PLOTTER::StartPlot()
time_t time1970 = time( NULL ); time_t time1970 = time( NULL );
fputs( "%!PS-Adobe-3.0\n", outputFile ); // Print header fputs( "%!PS-Adobe-3.0\n", m_outputFile ); // Print header
fprintf( outputFile, "%%%%Creator: %s\n", TO_UTF8( creator ) ); fprintf( m_outputFile, "%%%%Creator: %s\n", TO_UTF8( m_creator ) );
/* A "newline" character ("\n") is not included in the following string, /* A "newline" character ("\n") is not included in the following string,
because it is provided by the ctime() function. */ because it is provided by the ctime() function. */
fprintf( outputFile, "%%%%CreationDate: %s", ctime( &time1970 ) ); fprintf( m_outputFile, "%%%%CreationDate: %s", ctime( &time1970 ) );
fprintf( outputFile, "%%%%Title: %s\n", encodeStringForPlotter( title ).c_str() ); fprintf( m_outputFile, "%%%%Title: %s\n", encodeStringForPlotter( m_title ).c_str() );
fprintf( outputFile, "%%%%Pages: 1\n" ); fprintf( m_outputFile, "%%%%Pages: 1\n" );
fprintf( outputFile, "%%%%PageOrder: Ascend\n" ); fprintf( m_outputFile, "%%%%PageOrder: Ascend\n" );
// Print boundary box in 1/72 pixels per inch, box is in mils // Print boundary box in 1/72 pixels per inch, box is in mils
const double BIGPTsPERMIL = 0.072; const double BIGPTsPERMIL = 0.072;
@ -898,14 +900,14 @@ bool PS_PLOTTER::StartPlot()
/* The coordinates of the lower left corner of the boundary /* The coordinates of the lower left corner of the boundary
box need to be "rounded down", but the coordinates of its box need to be "rounded down", but the coordinates of its
upper right corner need to be "rounded up" instead. */ upper right corner need to be "rounded up" instead. */
wxSize psPaperSize = pageInfo.GetSizeMils(); wxSize psPaperSize = m_pageInfo.GetSizeMils();
if( !pageInfo.IsPortrait() ) if( !m_pageInfo.IsPortrait() )
psPaperSize.Set( pageInfo.GetHeightMils(), pageInfo.GetWidthMils() ); psPaperSize.Set( m_pageInfo.GetHeightMils(), m_pageInfo.GetWidthMils() );
fprintf( outputFile, "%%%%BoundingBox: 0 0 %d %d\n", fprintf( m_outputFile, "%%%%BoundingBox: 0 0 %d %d\n",
(int) ceil( psPaperSize.x * BIGPTsPERMIL ), (int) ceil( psPaperSize.x * BIGPTsPERMIL ),
(int) ceil( psPaperSize.y * BIGPTsPERMIL ) ); (int) ceil( psPaperSize.y * BIGPTsPERMIL ) );
// Specify the size of the sheet and the name associated with that size. // Specify the size of the sheet and the name associated with that size.
// (If the "User size" option has been selected for the sheet size, // (If the "User size" option has been selected for the sheet size,
@ -922,29 +924,32 @@ bool PS_PLOTTER::StartPlot()
// Also note pageSize is given in mils, not in internal units and must be // Also note pageSize is given in mils, not in internal units and must be
// converted to internal units. // converted to internal units.
if( pageInfo.IsCustom() ) if( m_pageInfo.IsCustom() )
fprintf( outputFile, "%%%%DocumentMedia: Custom %d %d 0 () ()\n", {
fprintf( m_outputFile, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
KiROUND( psPaperSize.x * BIGPTsPERMIL ), KiROUND( psPaperSize.x * BIGPTsPERMIL ),
KiROUND( psPaperSize.y * BIGPTsPERMIL ) ); KiROUND( psPaperSize.y * BIGPTsPERMIL ) );
}
else // a standard paper size else // a standard paper size
fprintf( outputFile, "%%%%DocumentMedia: %s %d %d 0 () ()\n", {
TO_UTF8( pageInfo.GetType() ), fprintf( m_outputFile, "%%%%DocumentMedia: %s %d %d 0 () ()\n",
TO_UTF8( m_pageInfo.GetType() ),
KiROUND( psPaperSize.x * BIGPTsPERMIL ), KiROUND( psPaperSize.x * BIGPTsPERMIL ),
KiROUND( psPaperSize.y * BIGPTsPERMIL ) ); KiROUND( psPaperSize.y * BIGPTsPERMIL ) );
}
if( pageInfo.IsPortrait() ) if( m_pageInfo.IsPortrait() )
fprintf( outputFile, "%%%%Orientation: Portrait\n" ); fprintf( m_outputFile, "%%%%Orientation: Portrait\n" );
else else
fprintf( outputFile, "%%%%Orientation: Landscape\n" ); fprintf( m_outputFile, "%%%%Orientation: Landscape\n" );
fprintf( outputFile, "%%%%EndComments\n" ); fprintf( m_outputFile, "%%%%EndComments\n" );
// Now specify various other details. // Now specify various other details.
for( int ii = 0; PSMacro[ii] != NULL; ii++ ) for( int ii = 0; PSMacro[ii] != NULL; ii++ )
{ {
fputs( PSMacro[ii], outputFile ); fputs( PSMacro[ii], m_outputFile );
} }
// The following string has been specified here (rather than within // The following string has been specified here (rather than within
@ -955,21 +960,21 @@ bool PS_PLOTTER::StartPlot()
"%%BeginPageSetup\n" "%%BeginPageSetup\n"
"gsave\n" "gsave\n"
"0.0072 0.0072 scale\n" // Configure postscript for decimils coordinates "0.0072 0.0072 scale\n" // Configure postscript for decimils coordinates
"linemode1\n", outputFile ); "linemode1\n", m_outputFile );
// Rototranslate the coordinate to achieve the landscape layout // Rototranslate the coordinate to achieve the landscape layout
if( !pageInfo.IsPortrait() ) if( !m_pageInfo.IsPortrait() )
fprintf( outputFile, "%d 0 translate 90 rotate\n", 10 * psPaperSize.x ); fprintf( m_outputFile, "%d 0 translate 90 rotate\n", 10 * psPaperSize.x );
// Apply the user fine scale adjustments // Apply the user fine scale adjustments
if( plotScaleAdjX != 1.0 || plotScaleAdjY != 1.0 ) if( plotScaleAdjX != 1.0 || plotScaleAdjY != 1.0 )
fprintf( outputFile, "%g %g scale\n", plotScaleAdjX, plotScaleAdjY ); fprintf( m_outputFile, "%g %g scale\n", plotScaleAdjX, plotScaleAdjY );
// Set default line width // Set default line width
fprintf( outputFile, "%g setlinewidth\n", fprintf( m_outputFile, "%g setlinewidth\n",
userToDeviceSize( m_renderSettings->GetDefaultPenWidth() ) ); userToDeviceSize( m_renderSettings->GetDefaultPenWidth() ) );
fputs( "%%EndPageSetup\n", outputFile ); fputs( "%%EndPageSetup\n", m_outputFile );
return true; return true;
} }
@ -977,12 +982,12 @@ bool PS_PLOTTER::StartPlot()
bool PS_PLOTTER::EndPlot() bool PS_PLOTTER::EndPlot()
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
fputs( "showpage\n" fputs( "showpage\n"
"grestore\n" "grestore\n"
"%%EOF\n", outputFile ); "%%EOF\n", m_outputFile );
fclose( outputFile ); fclose( m_outputFile );
outputFile = NULL; m_outputFile = NULL;
return true; return true;
} }
@ -1010,7 +1015,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
{ {
std::string ps_test = encodeStringForPlotter( aText ); std::string ps_test = encodeStringForPlotter( aText );
DPOINT pos_dev = userToDeviceCoordinates( aPos ); DPOINT pos_dev = userToDeviceCoordinates( aPos );
fprintf( outputFile, "%s %g %g phantomshow\n", ps_test.c_str(), pos_dev.x, pos_dev.y ); fprintf( m_outputFile, "%s %g %g phantomshow\n", ps_test.c_str(), pos_dev.x, pos_dev.y );
} }
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth,

View File

@ -178,16 +178,16 @@ SVG_PLOTTER::SVG_PLOTTER()
void SVG_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, void SVG_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ) double aScale, bool aMirror )
{ {
m_plotMirror = aMirror; m_plotMirror = aMirror;
m_yaxisReversed = true; // unlike other plotters, SVG has Y axis reversed m_yaxisReversed = true; // unlike other plotters, SVG has Y axis reversed
plotOffset = aOffset; m_plotOffset = aOffset;
plotScale = aScale; m_plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil; m_IUsPerDecimil = aIusPerDecimil;
/* Compute the paper size in IUs */ /* Compute the paper size in IUs */
paperSize = pageInfo.GetSizeMils(); m_paperSize = m_pageInfo.GetSizeMils();
paperSize.x *= 10.0 * aIusPerDecimil; m_paperSize.x *= 10.0 * aIusPerDecimil;
paperSize.y *= 10.0 * aIusPerDecimil; m_paperSize.y *= 10.0 * aIusPerDecimil;
// set iuPerDeviceUnit, in 0.1mils ( 2.54um ) // set iuPerDeviceUnit, in 0.1mils ( 2.54um )
// this was used before the format was changable, so we set is as default // this was used before the format was changable, so we set is as default
@ -201,10 +201,10 @@ void SVG_PLOTTER::SetSvgCoordinatesFormat( unsigned aResolution, bool aUseInches
// gives now a default value to iuPerDeviceUnit (because the units of the caller is now known) // gives now a default value to iuPerDeviceUnit (because the units of the caller is now known)
double iusPerMM = m_IUsPerDecimil / 2.54 * 1000; double iusPerMM = m_IUsPerDecimil / 2.54 * 1000;
iuPerDeviceUnit = pow( 10.0, m_precision ) / ( iusPerMM ); m_iuPerDeviceUnit = pow( 10.0, m_precision ) / ( iusPerMM );
if( m_useInch ) if( m_useInch )
iuPerDeviceUnit /= 25.4; // convert to inch m_iuPerDeviceUnit /= 25.4; // convert to inch
} }
@ -230,23 +230,23 @@ void SVG_PLOTTER::setFillMode( FILL_TYPE fill )
void SVG_PLOTTER::setSVGPlotStyle( bool aIsGroup, const std::string& aExtraStyle ) void SVG_PLOTTER::setSVGPlotStyle( bool aIsGroup, const std::string& aExtraStyle )
{ {
if( aIsGroup ) if( aIsGroup )
fputs( "</g>\n<g ", outputFile ); fputs( "</g>\n<g ", m_outputFile );
// output the background fill color // output the background fill color
fprintf( outputFile, "style=\"fill:#%6.6lX; ", m_brush_rgb_color ); fprintf( m_outputFile, "style=\"fill:#%6.6lX; ", m_brush_rgb_color );
switch( m_fillMode ) switch( m_fillMode )
{ {
case FILL_TYPE::NO_FILL: case FILL_TYPE::NO_FILL:
fputs( "fill-opacity:0.0; ", outputFile ); fputs( "fill-opacity:0.0; ", m_outputFile );
break; break;
case FILL_TYPE::FILLED_SHAPE: case FILL_TYPE::FILLED_SHAPE:
fputs( "fill-opacity:1.0; ", outputFile ); fputs( "fill-opacity:1.0; ", m_outputFile );
break; break;
case FILL_TYPE::FILLED_WITH_BG_BODYCOLOR: case FILL_TYPE::FILLED_WITH_BG_BODYCOLOR:
fputs( "fill-opacity:0.6; ", outputFile ); fputs( "fill-opacity:0.6; ", m_outputFile );
break; break;
case FILL_TYPE::FILLED_WITH_COLOR: case FILL_TYPE::FILLED_WITH_COLOR:
@ -259,22 +259,22 @@ void SVG_PLOTTER::setSVGPlotStyle( bool aIsGroup, const std::string& aExtraStyle
if( pen_w < 0.0 ) // Ensure pen width validity if( pen_w < 0.0 ) // Ensure pen width validity
pen_w = 0.0; pen_w = 0.0;
fprintf( outputFile, "\nstroke:#%6.6lX; stroke-width:%f; stroke-opacity:1; \n", fprintf( m_outputFile, "\nstroke:#%6.6lX; stroke-width:%f; stroke-opacity:1; \n",
m_pen_rgb_color, pen_w ); m_pen_rgb_color, pen_w );
fputs( "stroke-linecap:round; stroke-linejoin:round;", outputFile ); fputs( "stroke-linecap:round; stroke-linejoin:round;", m_outputFile );
//set any extra attributes for non-solid lines //set any extra attributes for non-solid lines
switch( m_dashed ) switch( m_dashed )
{ {
case PLOT_DASH_TYPE::DASH: case PLOT_DASH_TYPE::DASH:
fprintf( outputFile, "stroke-dasharray:%f,%f;", GetDashMarkLenIU(), GetDashGapLenIU() ); fprintf( m_outputFile, "stroke-dasharray:%f,%f;", GetDashMarkLenIU(), GetDashGapLenIU() );
break; break;
case PLOT_DASH_TYPE::DOT: case PLOT_DASH_TYPE::DOT:
fprintf( outputFile, "stroke-dasharray:%f,%f;", GetDotMarkLenIU(), GetDashGapLenIU() ); fprintf( m_outputFile, "stroke-dasharray:%f,%f;", GetDotMarkLenIU(), GetDashGapLenIU() );
break; break;
case PLOT_DASH_TYPE::DASHDOT: case PLOT_DASH_TYPE::DASHDOT:
fprintf( outputFile, "stroke-dasharray:%f,%f,%f,%f;", GetDashMarkLenIU(), GetDashGapLenIU(), fprintf( m_outputFile, "stroke-dasharray:%f,%f,%f,%f;", GetDashMarkLenIU(), GetDashGapLenIU(),
GetDotMarkLenIU(), GetDashGapLenIU() ); GetDotMarkLenIU(), GetDashGapLenIU() );
break; break;
case PLOT_DASH_TYPE::DEFAULT: case PLOT_DASH_TYPE::DEFAULT:
case PLOT_DASH_TYPE::SOLID: case PLOT_DASH_TYPE::SOLID:
@ -285,18 +285,18 @@ void SVG_PLOTTER::setSVGPlotStyle( bool aIsGroup, const std::string& aExtraStyle
if( aExtraStyle.length() ) if( aExtraStyle.length() )
{ {
fputs( aExtraStyle.c_str(), outputFile ); fputs( aExtraStyle.c_str(), m_outputFile );
} }
fputs( "\"", outputFile ); fputs( "\"", m_outputFile );
if( aIsGroup ) if( aIsGroup )
{ {
fputs( ">", outputFile ); fputs( ">", m_outputFile );
m_graphics_changed = false; m_graphics_changed = false;
} }
fputs( "\n", outputFile ); fputs( "\n", m_outputFile );
} }
/* Set the current line width (in IUs) for the next plot /* Set the current line width (in IUs) for the next plot
@ -312,10 +312,10 @@ void SVG_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData )
wxASSERT_MSG( aWidth > 0, "Plotter called to set negative pen width" ); wxASSERT_MSG( aWidth > 0, "Plotter called to set negative pen width" );
if( aWidth != currentPenWidth ) if( aWidth != m_currentPenWidth )
{ {
m_graphics_changed = true; m_graphics_changed = true;
currentPenWidth = aWidth; m_currentPenWidth = aWidth;
} }
if( m_graphics_changed ) if( m_graphics_changed )
@ -327,17 +327,18 @@ void SVG_PLOTTER::StartBlock( void* aData )
{ {
std::string* idstr = reinterpret_cast<std::string*>( aData ); std::string* idstr = reinterpret_cast<std::string*>( aData );
fputs( "<g ", outputFile ); fputs( "<g ", m_outputFile );
if( idstr )
fprintf( outputFile, "id=\"%s\"", idstr->c_str() );
fprintf( outputFile, ">\n" ); if( idstr )
fprintf( m_outputFile, "id=\"%s\"", idstr->c_str() );
fprintf( m_outputFile, ">\n" );
} }
void SVG_PLOTTER::EndBlock( void* aData ) void SVG_PLOTTER::EndBlock( void* aData )
{ {
fprintf( outputFile, "</g>\n" ); fprintf( m_outputFile, "</g>\n" );
m_graphics_changed = true; m_graphics_changed = true;
} }
@ -400,19 +401,20 @@ void SVG_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill, in
// Rectangles having a 0 size value for height or width are just not drawn on Inscape, // Rectangles having a 0 size value for height or width are just not drawn on Inscape,
// so use a line when happens. // so use a line when happens.
if( rect_dev.GetSize().x == 0.0 || rect_dev.GetSize().y == 0.0 ) // Draw a line if( rect_dev.GetSize().x == 0.0 || rect_dev.GetSize().y == 0.0 ) // Draw a line
fprintf( outputFile, {
fprintf( m_outputFile,
"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" />\n", "<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" />\n",
rect_dev.GetPosition().x, rect_dev.GetPosition().y, rect_dev.GetPosition().x, rect_dev.GetPosition().y,
rect_dev.GetEnd().x, rect_dev.GetEnd().y rect_dev.GetEnd().x, rect_dev.GetEnd().y );
); }
else else
fprintf( outputFile, {
fprintf( m_outputFile,
"<rect x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\" rx=\"%f\" />\n", "<rect x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\" rx=\"%f\" />\n",
rect_dev.GetPosition().x, rect_dev.GetPosition().y, rect_dev.GetPosition().x, rect_dev.GetPosition().y,
rect_dev.GetSize().x, rect_dev.GetSize().y, rect_dev.GetSize().x, rect_dev.GetSize().y,
0.0 // radius of rounded corners 0.0 /* radius of rounded corners */ );
); }
} }
@ -433,7 +435,7 @@ void SVG_PLOTTER::Circle( const wxPoint& pos, int diametre, FILL_TYPE fill, int
radius = userToDeviceSize( ( diametre / 2.0 ) + ( width / 2.0 ) ); radius = userToDeviceSize( ( diametre / 2.0 ) + ( width / 2.0 ) );
} }
fprintf( outputFile, fprintf( m_outputFile,
"<circle cx=\"%f\" cy=\"%f\" r=\"%f\" /> \n", "<circle cx=\"%f\" cy=\"%f\" r=\"%f\" /> \n",
pos_dev.x, pos_dev.y, radius ); pos_dev.x, pos_dev.y, radius );
} }
@ -526,7 +528,7 @@ void SVG_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
setFillMode( fill ); setFillMode( fill );
SetCurrentLineWidth( 0 ); SetCurrentLineWidth( 0 );
fprintf( outputFile, "<path d=\"M%f %f A%f %f 0.0 %d %d %f %f L %f %f Z\" />\n", fprintf( m_outputFile, "<path d=\"M%f %f A%f %f 0.0 %d %d %f %f L %f %f Z\" />\n",
start.x, start.y, radius_dev, radius_dev, start.x, start.y, radius_dev, radius_dev,
flg_arc, flg_sweep, flg_arc, flg_sweep,
end.x, end.y, centre_dev.x, centre_dev.y ); end.x, end.y, centre_dev.x, centre_dev.y );
@ -534,7 +536,7 @@ void SVG_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
setFillMode( FILL_TYPE::NO_FILL ); setFillMode( FILL_TYPE::NO_FILL );
SetCurrentLineWidth( width ); SetCurrentLineWidth( width );
fprintf( outputFile, "<path d=\"M%f %f A%f %f 0.0 %d %d %f %f\" />\n", fprintf( m_outputFile, "<path d=\"M%f %f A%f %f 0.0 %d %d %f %f\" />\n",
start.x, start.y, radius_dev, radius_dev, start.x, start.y, radius_dev, radius_dev,
flg_arc, flg_sweep, flg_arc, flg_sweep,
end.x, end.y ); end.x, end.y );
@ -555,7 +557,7 @@ void SVG_PLOTTER::BezierCurve( const wxPoint& aStart, const wxPoint& aControl1,
DPOINT end = userToDeviceCoordinates( aEnd ); DPOINT end = userToDeviceCoordinates( aEnd );
// Generate a cubic curve: start point and 3 other control points. // Generate a cubic curve: start point and 3 other control points.
fprintf( outputFile, "<path d=\"M%f,%f C%f,%f %f,%f %f,%f\" />\n", fprintf( m_outputFile, "<path d=\"M%f,%f C%f,%f %f,%f %f,%f\" />\n",
start.x, start.y, ctrl1.x, ctrl1.y, start.x, start.y, ctrl1.x, ctrl1.y,
ctrl2.x, ctrl2.y, end.x, end.y ); ctrl2.x, ctrl2.y, end.x, end.y );
#else #else
@ -572,7 +574,7 @@ void SVG_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
setFillMode( aFill ); setFillMode( aFill );
SetCurrentLineWidth( aWidth ); SetCurrentLineWidth( aWidth );
fprintf( outputFile, "<path "); fprintf( m_outputFile, "<path ");
switch( aFill ) switch( aFill )
{ {
@ -591,21 +593,21 @@ void SVG_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
} }
DPOINT pos = userToDeviceCoordinates( aCornerList[0] ); DPOINT pos = userToDeviceCoordinates( aCornerList[0] );
fprintf( outputFile, "d=\"M %f,%f\n", pos.x, pos.y ); fprintf( m_outputFile, "d=\"M %f,%f\n", pos.x, pos.y );
for( unsigned ii = 1; ii < aCornerList.size() - 1; ii++ ) for( unsigned ii = 1; ii < aCornerList.size() - 1; ii++ )
{ {
pos = userToDeviceCoordinates( aCornerList[ii] ); pos = userToDeviceCoordinates( aCornerList[ii] );
fprintf( outputFile, "%f,%f\n", pos.x, pos.y ); fprintf( m_outputFile, "%f,%f\n", pos.x, pos.y );
} }
// If the cornerlist ends where it begins, then close the poly // If the cornerlist ends where it begins, then close the poly
if( aCornerList.front() == aCornerList.back() ) if( aCornerList.front() == aCornerList.back() )
fprintf( outputFile, "Z\" /> \n" ); fprintf( m_outputFile, "Z\" /> \n" );
else else
{ {
pos = userToDeviceCoordinates( aCornerList.back() ); pos = userToDeviceCoordinates( aCornerList.back() );
fprintf( outputFile, "%f,%f\n\" /> \n", pos.x, pos.y ); fprintf( m_outputFile, "%f,%f\n\" /> \n", pos.x, pos.y );
} }
} }
@ -644,21 +646,21 @@ void SVG_PLOTTER::PlotImage( const wxImage& aImage, const wxPoint& aPos,
img_stream.CopyTo( buffer.data(), buffer.size() ); img_stream.CopyTo( buffer.data(), buffer.size() );
base64::encode( buffer, encoded ); base64::encode( buffer, encoded );
fprintf( outputFile, fprintf( m_outputFile,
"<image x=\"%f\" y=\"%f\" xlink:href=\"data:image/png;base64,", "<image x=\"%f\" y=\"%f\" xlink:href=\"data:image/png;base64,",
userToDeviceSize( start.x ), userToDeviceSize( start.y ) userToDeviceSize( start.x ), userToDeviceSize( start.y )
); );
for( size_t i = 0; i < encoded.size(); i++ ) for( size_t i = 0; i < encoded.size(); i++ )
{ {
fprintf( outputFile, "%c", static_cast<char>( encoded[i] ) ); fprintf( m_outputFile, "%c", static_cast<char>( encoded[i] ) );
if( ( i % 64 ) == 63 ) if( ( i % 64 ) == 63 )
fprintf( outputFile, "\n" ); fprintf( m_outputFile, "\n" );
} }
fprintf( outputFile, "\"\npreserveAspectRatio=\"none\" width=\"%f\" height=\"%f\" />", fprintf( m_outputFile, "\"\npreserveAspectRatio=\"none\" width=\"%f\" height=\"%f\" />",
userToDeviceSize( drawsize.x ), userToDeviceSize( drawsize.y ) ); userToDeviceSize( drawsize.x ), userToDeviceSize( drawsize.y ) );
} }
} }
@ -667,18 +669,18 @@ void SVG_PLOTTER::PenTo( const wxPoint& pos, char plume )
{ {
if( plume == 'Z' ) if( plume == 'Z' )
{ {
if( penState != 'Z' ) if( m_penState != 'Z' )
{ {
fputs( "\" />\n", outputFile ); fputs( "\" />\n", m_outputFile );
penState = 'Z'; m_penState = 'Z';
penLastpos.x = -1; m_penLastpos.x = -1;
penLastpos.y = -1; m_penLastpos.y = -1;
} }
return; return;
} }
if( penState == 'Z' ) // here plume = 'D' or 'U' if( m_penState == 'Z' ) // here plume = 'D' or 'U'
{ {
DPOINT pos_dev = userToDeviceCoordinates( pos ); DPOINT pos_dev = userToDeviceCoordinates( pos );
@ -690,18 +692,18 @@ void SVG_PLOTTER::PenTo( const wxPoint& pos, char plume )
setSVGPlotStyle(); setSVGPlotStyle();
} }
fprintf( outputFile, "<path d=\"M%d %d\n", fprintf( m_outputFile, "<path d=\"M%d %d\n",
(int) pos_dev.x, (int) pos_dev.y ); (int) pos_dev.x, (int) pos_dev.y );
} }
else if( penState != plume || pos != penLastpos ) else if( m_penState != plume || pos != m_penLastpos )
{ {
DPOINT pos_dev = userToDeviceCoordinates( pos ); DPOINT pos_dev = userToDeviceCoordinates( pos );
fprintf( outputFile, "L%d %d\n", fprintf( m_outputFile, "L%d %d\n",
(int) pos_dev.x, (int) pos_dev.y ); (int) pos_dev.x, (int) pos_dev.y );
} }
penState = plume; m_penState = plume;
penLastpos = pos; m_penLastpos = pos;
} }
@ -711,7 +713,7 @@ void SVG_PLOTTER::PenTo( const wxPoint& pos, char plume )
*/ */
bool SVG_PLOTTER::StartPlot() bool SVG_PLOTTER::StartPlot()
{ {
wxASSERT( outputFile ); wxASSERT( m_outputFile );
wxString msg; wxString msg;
static const char* header[] = static const char* header[] =
@ -730,15 +732,15 @@ bool SVG_PLOTTER::StartPlot()
// Write header. // Write header.
for( int ii = 0; header[ii] != NULL; ii++ ) for( int ii = 0; header[ii] != NULL; ii++ )
{ {
fputs( header[ii], outputFile ); fputs( header[ii], m_outputFile );
} }
// Write viewport pos and size // Write viewport pos and size
wxPoint origin; // TODO set to actual value wxPoint origin; // TODO set to actual value
fprintf( outputFile, " width=\"%fcm\" height=\"%fcm\" viewBox=\"%d %d %d %d\">\n", fprintf( m_outputFile, " width=\"%fcm\" height=\"%fcm\" viewBox=\"%d %d %d %d\">\n",
(double) paperSize.x / m_IUsPerDecimil * 2.54 / 10000, (double) m_paperSize.x / m_IUsPerDecimil * 2.54 / 10000,
(double) paperSize.y / m_IUsPerDecimil * 2.54 / 10000, origin.x, origin.y, (double) m_paperSize.y / m_IUsPerDecimil * 2.54 / 10000, origin.x, origin.y,
(int) ( paperSize.x * iuPerDeviceUnit ), (int) ( paperSize.y * iuPerDeviceUnit) ); (int) ( m_paperSize.x * m_iuPerDeviceUnit ), (int) ( m_paperSize.y * m_iuPerDeviceUnit) );
// Write title // Write title
char date_buf[250]; char date_buf[250];
@ -746,31 +748,31 @@ bool SVG_PLOTTER::StartPlot()
strftime( date_buf, 250, "%Y/%m/%d %H:%M:%S", strftime( date_buf, 250, "%Y/%m/%d %H:%M:%S",
localtime( &ltime ) ); localtime( &ltime ) );
fprintf( outputFile, fprintf( m_outputFile,
"<title>SVG Picture created as %s date %s </title>\n", "<title>SVG Picture created as %s date %s </title>\n",
TO_UTF8( XmlEsc( wxFileName( filename ).GetFullName() ) ), date_buf ); TO_UTF8( XmlEsc( wxFileName( m_filename ).GetFullName() ) ), date_buf );
// End of header // End of header
fprintf( outputFile, " <desc>Picture generated by %s </desc>\n", fprintf( m_outputFile, " <desc>Picture generated by %s </desc>\n",
TO_UTF8( XmlEsc( creator ) ) ); TO_UTF8( XmlEsc( m_creator ) ) );
// output the pen and brush color (RVB values in hex) and opacity // output the pen and brush color (RVB values in hex) and opacity
double opacity = 1.0; // 0.0 (transparent to 1.0 (solid) double opacity = 1.0; // 0.0 (transparent to 1.0 (solid)
fprintf( outputFile, fprintf( m_outputFile,
"<g style=\"fill:#%6.6lX; fill-opacity:%f;stroke:#%6.6lX; stroke-opacity:%f;\n", "<g style=\"fill:#%6.6lX; fill-opacity:%f;stroke:#%6.6lX; stroke-opacity:%f;\n",
m_brush_rgb_color, opacity, m_pen_rgb_color, opacity ); m_brush_rgb_color, opacity, m_pen_rgb_color, opacity );
// output the pen cap and line joint // output the pen cap and line joint
fputs( "stroke-linecap:round; stroke-linejoin:round;\"\n", outputFile ); fputs( "stroke-linecap:round; stroke-linejoin:round;\"\n", m_outputFile );
fputs( " transform=\"translate(0 0) scale(1 1)\">\n", outputFile ); fputs( " transform=\"translate(0 0) scale(1 1)\">\n", m_outputFile );
return true; return true;
} }
bool SVG_PLOTTER::EndPlot() bool SVG_PLOTTER::EndPlot()
{ {
fputs( "</g> \n</svg>\n", outputFile ); fputs( "</g> \n</svg>\n", m_outputFile );
fclose( outputFile ); fclose( m_outputFile );
outputFile = NULL; m_outputFile = NULL;
return true; return true;
} }
@ -835,31 +837,31 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
DPOINT sz_dev = userToDeviceSize( text_size ); DPOINT sz_dev = userToDeviceSize( text_size );
if( aOrient != 0 ) { if( aOrient != 0 ) {
fprintf( outputFile, fprintf( m_outputFile,
"<g transform=\"rotate(%f %f %f)\">\n", "<g transform=\"rotate(%f %f %f)\">\n",
- aOrient * 0.1, anchor_pos_dev.x, anchor_pos_dev.y ); - aOrient * 0.1, anchor_pos_dev.x, anchor_pos_dev.y );
} }
fprintf( outputFile, fprintf( m_outputFile,
"<text x=\"%f\" y=\"%f\"\n", text_pos_dev.x, text_pos_dev.y ); "<text x=\"%f\" y=\"%f\"\n", text_pos_dev.x, text_pos_dev.y );
/// If the text is mirrored, we should also mirror the hidden text to match /// If the text is mirrored, we should also mirror the hidden text to match
if( aSize.x < 0 ) if( aSize.x < 0 )
fprintf( outputFile, "transform=\"scale(-1 1) translate(%f 0)\"\n", -2 * text_pos_dev.x ); fprintf( m_outputFile, "transform=\"scale(-1 1) translate(%f 0)\"\n", -2 * text_pos_dev.x );
fprintf( outputFile, fprintf( m_outputFile,
"textLength=\"%f\" font-size=\"%f\" lengthAdjust=\"spacingAndGlyphs\"\n" "textLength=\"%f\" font-size=\"%f\" lengthAdjust=\"spacingAndGlyphs\"\n"
"text-anchor=\"%s\" opacity=\"0\">%s</text>\n", "text-anchor=\"%s\" opacity=\"0\">%s</text>\n",
sz_dev.x, sz_dev.y, sz_dev.x, sz_dev.y,
hjust, TO_UTF8( XmlEsc( aText ) ) ); hjust, TO_UTF8( XmlEsc( aText ) ) );
if( aOrient != 0 ) if( aOrient != 0 )
fputs( "</g>\n", outputFile ); fputs( "</g>\n", m_outputFile );
fprintf( outputFile, fprintf( m_outputFile,
"<g class=\"stroked-text\"><desc>%s</desc>\n", "<g class=\"stroked-text\"><desc>%s</desc>\n",
TO_UTF8( XmlEsc( aText ) ) ); TO_UTF8( XmlEsc( aText ) ) );
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
aWidth, aItalic, aBold, aMultilineAllowed ); aWidth, aItalic, aBold, aMultilineAllowed );
fputs( "</g>", outputFile ); fputs( "</g>", m_outputFile );
} }

View File

@ -49,18 +49,18 @@
PLOTTER::PLOTTER( ) PLOTTER::PLOTTER( )
{ {
plotScale = 1; m_plotScale = 1;
currentPenWidth = -1; // To-be-set marker m_currentPenWidth = -1; // To-be-set marker
penState = 'Z'; // End-of-path idle m_penState = 'Z'; // End-of-path idle
m_plotMirror = false; // Plot mirror option flag m_plotMirror = false; // Plot mirror option flag
m_mirrorIsHorizontal = true; m_mirrorIsHorizontal = true;
m_yaxisReversed = false; m_yaxisReversed = false;
outputFile = 0; m_outputFile = 0;
colorMode = false; // Starts as a BW plot m_colorMode = false; // Starts as a BW plot
negativeMode = false; m_negativeMode = false;
// Temporary init to avoid not initialized vars, will be set later // Temporary init to avoid not initialized vars, will be set later
m_IUsPerDecimil = 1; // will be set later to the actual value m_IUsPerDecimil = 1; // will be set later to the actual value
iuPerDeviceUnit = 1; // will be set later to the actual value m_iuPerDeviceUnit = 1; // will be set later to the actual value
m_renderSettings = nullptr; m_renderSettings = nullptr;
} }
@ -68,22 +68,22 @@ PLOTTER::~PLOTTER()
{ {
// Emergency cleanup, but closing the file is // Emergency cleanup, but closing the file is
// usually made in EndPlot(). // usually made in EndPlot().
if( outputFile ) if( m_outputFile )
fclose( outputFile ); fclose( m_outputFile );
} }
bool PLOTTER::OpenFile( const wxString& aFullFilename ) bool PLOTTER::OpenFile( const wxString& aFullFilename )
{ {
filename = aFullFilename; m_filename = aFullFilename;
wxASSERT( !outputFile ); wxASSERT( !m_outputFile );
// Open the file in text mode (not suitable for all plotters // Open the file in text mode (not suitable for all plotters
// but only for most of them // but only for most of them
outputFile = wxFopen( filename, wxT( "wt" ) ); m_outputFile = wxFopen( m_filename, wxT( "wt" ) );
if( outputFile == NULL ) if( m_outputFile == NULL )
return false ; return false ;
return true; return true;
@ -92,7 +92,7 @@ bool PLOTTER::OpenFile( const wxString& aFullFilename )
DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& aCoordinate ) DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& aCoordinate )
{ {
wxPoint pos = aCoordinate - plotOffset; wxPoint pos = aCoordinate - m_plotOffset;
// Don't allow overflows; they can cause rendering failures in some file viewers // Don't allow overflows; they can cause rendering failures in some file viewers
// (such as Acrobat) // (such as Acrobat)
@ -100,22 +100,22 @@ DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& aCoordinate )
pos.x = std::max( -clampSize, std::min( pos.x, clampSize ) ); pos.x = std::max( -clampSize, std::min( pos.x, clampSize ) );
pos.y = std::max( -clampSize, std::min( pos.y, clampSize ) ); pos.y = std::max( -clampSize, std::min( pos.y, clampSize ) );
double x = pos.x * plotScale; double x = pos.x * m_plotScale;
double y = ( paperSize.y - pos.y * plotScale ); double y = ( m_paperSize.y - pos.y * m_plotScale );
if( m_plotMirror ) if( m_plotMirror )
{ {
if( m_mirrorIsHorizontal ) if( m_mirrorIsHorizontal )
x = ( paperSize.x - pos.x * plotScale ); x = ( m_paperSize.x - pos.x * m_plotScale );
else else
y = pos.y * plotScale; y = pos.y * m_plotScale;
} }
if( m_yaxisReversed ) if( m_yaxisReversed )
y = paperSize.y - y; y = m_paperSize.y - y;
x *= iuPerDeviceUnit; x *= m_iuPerDeviceUnit;
y *= iuPerDeviceUnit; y *= m_iuPerDeviceUnit;
return DPOINT( x, y ); return DPOINT( x, y );
} }
@ -123,14 +123,14 @@ DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& aCoordinate )
DPOINT PLOTTER::userToDeviceSize( const wxSize& size ) DPOINT PLOTTER::userToDeviceSize( const wxSize& size )
{ {
return DPOINT( size.x * plotScale * iuPerDeviceUnit, return DPOINT( size.x * m_plotScale * m_iuPerDeviceUnit,
size.y * plotScale * iuPerDeviceUnit ); size.y * m_plotScale * m_iuPerDeviceUnit );
} }
double PLOTTER::userToDeviceSize( double size ) const double PLOTTER::userToDeviceSize( double size ) const
{ {
return size * plotScale * iuPerDeviceUnit; return size * m_plotScale * m_iuPerDeviceUnit;
} }
@ -458,7 +458,7 @@ void PLOTTER::segmentAsOval( const wxPoint& start, const wxPoint& end, int width
void PLOTTER::sketchOval( const wxPoint& pos, const wxSize& aSize, double orient, int width ) void PLOTTER::sketchOval( const wxPoint& pos, const wxSize& aSize, double orient, int width )
{ {
SetCurrentLineWidth( width ); SetCurrentLineWidth( width );
width = currentPenWidth; width = m_currentPenWidth;
int radius, deltaxy, cx, cy; int radius, deltaxy, cx, cy;
wxSize size( aSize ); wxSize size( aSize );
@ -536,9 +536,9 @@ void PLOTTER::ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
{ {
SetCurrentLineWidth( -1 ); SetCurrentLineWidth( -1 );
Arc( centre, StAngle, EndAngle, Arc( centre, StAngle, EndAngle,
radius - ( width - currentPenWidth ) / 2, FILL_TYPE::NO_FILL, -1 ); radius - ( width - m_currentPenWidth ) / 2, FILL_TYPE::NO_FILL, -1 );
Arc( centre, StAngle, EndAngle, Arc( centre, StAngle, EndAngle,
radius + ( width - currentPenWidth ) / 2, FILL_TYPE::NO_FILL, -1 ); radius + ( width - m_currentPenWidth ) / 2, FILL_TYPE::NO_FILL, -1 );
} }
} }
@ -551,15 +551,15 @@ void PLOTTER::ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
else else
{ {
SetCurrentLineWidth( -1 ); SetCurrentLineWidth( -1 );
wxPoint offsetp1( p1.x - (width - currentPenWidth) / 2, wxPoint offsetp1( p1.x - (width - m_currentPenWidth) / 2,
p1.y - (width - currentPenWidth) / 2 ); p1.y - (width - m_currentPenWidth) / 2 );
wxPoint offsetp2( p2.x + (width - currentPenWidth) / 2, wxPoint offsetp2( p2.x + (width - m_currentPenWidth) / 2,
p2.y + (width - currentPenWidth) / 2 ); p2.y + (width - m_currentPenWidth) / 2 );
Rect( offsetp1, offsetp2, FILL_TYPE::NO_FILL, -1 ); Rect( offsetp1, offsetp2, FILL_TYPE::NO_FILL, -1 );
offsetp1.x += (width - currentPenWidth); offsetp1.x += (width - m_currentPenWidth);
offsetp1.y += (width - currentPenWidth); offsetp1.y += (width - m_currentPenWidth);
offsetp2.x -= (width - currentPenWidth); offsetp2.x -= (width - m_currentPenWidth);
offsetp2.y -= (width - currentPenWidth); offsetp2.y -= (width - m_currentPenWidth);
Rect( offsetp1, offsetp2, FILL_TYPE::NO_FILL, -1 ); Rect( offsetp1, offsetp2, FILL_TYPE::NO_FILL, -1 );
} }
} }
@ -575,8 +575,8 @@ void PLOTTER::ThickCircle( const wxPoint& pos, int diametre, int width, OUTLINE_
else else
{ {
SetCurrentLineWidth( -1 ); SetCurrentLineWidth( -1 );
Circle( pos, diametre - width + currentPenWidth, FILL_TYPE::NO_FILL, -1 ); Circle( pos, diametre - width + m_currentPenWidth, FILL_TYPE::NO_FILL, -1 );
Circle( pos, diametre + width - currentPenWidth, FILL_TYPE::NO_FILL, -1 ); Circle( pos, diametre + width - m_currentPenWidth, FILL_TYPE::NO_FILL, -1 );
} }
} }

View File

@ -67,7 +67,7 @@ public:
// For now we don't use 'thick' primitives, so no line width // For now we don't use 'thick' primitives, so no line width
virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override
{ {
currentPenWidth = 0; m_currentPenWidth = 0;
} }
virtual void SetDash( PLOT_DASH_TYPE dashed ) override; virtual void SetDash( PLOT_DASH_TYPE dashed ) override;

View File

@ -53,7 +53,7 @@ public:
virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override
{ {
// This is the truth // This is the truth
currentPenWidth = userToDeviceSize( penDiameter ); m_currentPenWidth = userToDeviceSize( penDiameter );
} }
virtual void SetDash( PLOT_DASH_TYPE dashed ) override; virtual void SetDash( PLOT_DASH_TYPE dashed ) override;

View File

@ -151,21 +151,21 @@ public:
virtual void SetNegative( bool aNegative ) virtual void SetNegative( bool aNegative )
{ {
negativeMode = aNegative; m_negativeMode = aNegative;
} }
/** /**
* Plot in B/W or color. * Plot in B/W or color.
* @param aColorMode = true to plot in color, false to plot in black and white * @param aColorMode = true to plot in color, false to plot in black and white
*/ */
virtual void SetColorMode( bool aColorMode ) { colorMode = aColorMode; } virtual void SetColorMode( bool aColorMode ) { m_colorMode = aColorMode; }
bool GetColorMode() const { return colorMode; } bool GetColorMode() const { return m_colorMode; }
void SetRenderSettings( RENDER_SETTINGS* aSettings ) { m_renderSettings = aSettings; } void SetRenderSettings( RENDER_SETTINGS* aSettings ) { m_renderSettings = aSettings; }
RENDER_SETTINGS* RenderSettings() { return m_renderSettings; } RENDER_SETTINGS* RenderSettings() { return m_renderSettings; }
virtual void SetPageSettings( const PAGE_INFO& aPageSettings ) { pageInfo = aPageSettings; } virtual void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_pageInfo = aPageSettings; }
PAGE_INFO& PageSettings() { return pageInfo; } PAGE_INFO& PageSettings() { return m_pageInfo; }
/** /**
* Set the line width for the next drawing. * Set the line width for the next drawing.
@ -173,21 +173,15 @@ public:
* @param aData is an auxiliary parameter, mainly used in gerber plotter * @param aData is an auxiliary parameter, mainly used in gerber plotter
*/ */
virtual void SetCurrentLineWidth( int width, void* aData = NULL ) = 0; virtual void SetCurrentLineWidth( int width, void* aData = NULL ) = 0;
virtual int GetCurrentLineWidth() const { return currentPenWidth; } virtual int GetCurrentLineWidth() const { return m_currentPenWidth; }
virtual void SetColor( COLOR4D color ) = 0; virtual void SetColor( COLOR4D color ) = 0;
virtual void SetDash( PLOT_DASH_TYPE dashed ) = 0; virtual void SetDash( PLOT_DASH_TYPE dashed ) = 0;
virtual void SetCreator( const wxString& aCreator ) virtual void SetCreator( const wxString& aCreator ) { m_creator = aCreator; }
{
creator = aCreator;
}
virtual void SetTitle( const wxString& aTitle ) virtual void SetTitle( const wxString& aTitle ) { m_title = aTitle; }
{
title = aTitle;
}
/** /**
* Add a line to the list of free lines to print at the beginning of the file * Add a line to the list of free lines to print at the beginning of the file
@ -575,43 +569,39 @@ protected:
protected: // variables used in most of plotters: protected: // variables used in most of plotters:
/// Plot scale - chosen by the user (even implicitly with 'fit in a4') /// Plot scale - chosen by the user (even implicitly with 'fit in a4')
double plotScale; double m_plotScale;
/* Caller scale (how many IUs in a decimil - always); it's a double /* Caller scale (how many IUs in a decimil - always); it's a double
* because in Eeschema there are 0.1 IUs in a decimil (Eeschema * because in Eeschema there are 0.1 IUs in a decimil (Eeschema
* always works in mils internally) while PcbNew can work in decimil * always works in mils internally) while PcbNew can work in decimil
* or nanometers, so this value would be >= 1 */ * or nanometers, so this value would be >= 1 */
double m_IUsPerDecimil; double m_IUsPerDecimil;
/// Device scale (from IUs to plotter device units - usually decimils) double m_iuPerDeviceUnit; // Device scale (from IUs to plotter device units;
double iuPerDeviceUnit; // usually decimils)
wxPoint m_plotOffset; // Plot offset (in IUs)
/// Plot offset (in IUs) bool m_plotMirror; // X axis orientation (SVG)
wxPoint plotOffset; // and plot mirrored (only for PS, PDF HPGL and SVG)
bool m_mirrorIsHorizontal; // true to mirror horizontally (else vertically)
/// X axis orientation (SVG) bool m_yaxisReversed; // true if the Y axis is top to bottom (SVG)
/// and plot mirrored (only for PS, PDF HPGL and SVG)
bool m_plotMirror;
bool m_mirrorIsHorizontal; /// true to mirror horizontally (else vertically)
bool m_yaxisReversed; /// true if the Y axis is top to bottom (SVG)
/// Output file /// Output file
FILE* outputFile; FILE* m_outputFile;
// Pen handling // Pen handling
bool colorMode; // true to plot in color, false to plot in black & white bool m_colorMode; // true to plot in color, otherwise black & white
bool negativeMode; // true to generate a negative image (PS mode mainly) bool m_negativeMode; // true to generate a negative image (PS mode mainly)
int currentPenWidth; int m_currentPenWidth;
char penState; // Current pen state: 'U', 'D' or 'Z' (see PenTo) char m_penState; // current pen state: 'U', 'D' or 'Z' (see PenTo)
wxPoint penLastpos; // Last pen positions; set to -1,-1 when the pen is wxPoint m_penLastpos; // last pen position; -1,-1 when pen is at rest
// at rest
wxString creator;
wxString filename;
wxString title;
PAGE_INFO pageInfo;
wxSize paperSize; // Paper size in IU - not in mils
wxArrayString m_headerExtraLines; // a set of string to print in header file wxString m_creator;
wxString m_filename;
wxString m_title;
PAGE_INFO m_pageInfo;
wxSize m_paperSize; // Paper size in IU - not in mils
wxArrayString m_headerExtraLines; // a set of string to print in header file
RENDER_SETTINGS* m_renderSettings; RENDER_SETTINGS* m_renderSettings;
}; };

View File

@ -384,7 +384,7 @@ void DIALOG_GENDRILL::GenDrillAndMapFiles( bool aGenDrill, bool aGenMap )
{ {
EXCELLON_WRITER excellonWriter( m_board ); EXCELLON_WRITER excellonWriter( m_board );
excellonWriter.SetFormat( !m_UnitDrillIsInch, (EXCELLON_WRITER::ZEROS_FMT) m_ZerosFormat, excellonWriter.SetFormat( !m_UnitDrillIsInch, (EXCELLON_WRITER::ZEROS_FMT) m_ZerosFormat,
m_Precision.m_lhs, m_Precision.m_rhs ); m_Precision.m_Lhs, m_Precision.m_Rhs );
excellonWriter.SetOptions( m_Mirror, m_MinimalHeader, m_FileDrillOffset, m_Merge_PTH_NPTH ); excellonWriter.SetOptions( m_Mirror, m_MinimalHeader, m_FileDrillOffset, m_Merge_PTH_NPTH );
excellonWriter.SetRouteModeForOvalHoles( m_UseRouteModeForOvalHoles ); excellonWriter.SetRouteModeForOvalHoles( m_UseRouteModeForOvalHoles );
excellonWriter.SetMapFileFormat( filefmt[choice] ); excellonWriter.SetMapFileFormat( filefmt[choice] );

View File

@ -64,27 +64,14 @@ public:
m_progressReporter = aProgressReporter; m_progressReporter = aProgressReporter;
} }
// fixme: don't directly expose any wx UI classes. Currently interface returns only
// an anonymous pointer so shouldn't introduce a dependency on wx unless wx is used
// by the particular exporter.
virtual wxDialog* CreateSettingsDialog( PROPERTIES* aProperties )
{
return nullptr;
}
virtual bool HasSettingsDialog() const
{
return false;
}
virtual bool Run() = 0; virtual bool Run() = 0;
protected: protected:
PROPERTIES m_properties; PROPERTIES m_properties;
BOARD* m_board = nullptr; BOARD* m_board = nullptr;
wxFileName m_outputFilePath; wxFileName m_outputFilePath;
REPORTER* m_reporter = nullptr; REPORTER* m_reporter = nullptr;
PROGRESS_REPORTER *m_progressReporter = nullptr; PROGRESS_REPORTER* m_progressReporter = nullptr;
}; };
#endif #endif

View File

@ -71,8 +71,7 @@ public:
void Write( const wxString& aFilename ); void Write( const wxString& aFilename );
private: private:
BOARD* m_pcb; BOARD* m_pcb;
wxWindow* m_parent; wxWindow* m_parent;
/// Writes a list of records to the given output stream /// Writes a list of records to the given output stream

View File

@ -89,7 +89,9 @@ static void idf_export_outline( BOARD* aPcb, IDF3_BOARD& aIDFBoard )
{ {
if( ( graphic->GetStart().x == graphic->GetEnd().x ) if( ( graphic->GetStart().x == graphic->GetEnd().x )
&& ( graphic->GetStart().y == graphic->GetEnd().y ) ) && ( graphic->GetStart().y == graphic->GetEnd().y ) )
{
break; break;
}
sp.x = graphic->GetStart().x * scale + offX; sp.x = graphic->GetStart().x * scale + offX;
sp.y = -graphic->GetStart().y * scale + offY; sp.y = -graphic->GetStart().y * scale + offY;
@ -106,7 +108,9 @@ static void idf_export_outline( BOARD* aPcb, IDF3_BOARD& aIDFBoard )
{ {
if( ( graphic->GetStart().x == graphic->GetEnd().x ) if( ( graphic->GetStart().x == graphic->GetEnd().x )
&& ( graphic->GetStart().y == graphic->GetEnd().y ) ) && ( graphic->GetStart().y == graphic->GetEnd().y ) )
{
break; break;
}
double top = graphic->GetStart().y * scale + offY; double top = graphic->GetStart().y * scale + offY;
double left = graphic->GetStart().x * scale + offX; double left = graphic->GetStart().x * scale + offX;
@ -130,7 +134,9 @@ static void idf_export_outline( BOARD* aPcb, IDF3_BOARD& aIDFBoard )
{ {
if( ( graphic->GetCenter().x == graphic->GetArcStart().x ) if( ( graphic->GetCenter().x == graphic->GetArcStart().x )
&& ( graphic->GetCenter().y == graphic->GetArcStart().y ) ) && ( graphic->GetCenter().y == graphic->GetArcStart().y ) )
{
break; break;
}
sp.x = graphic->GetCenter().x * scale + offX; sp.x = graphic->GetCenter().x * scale + offX;
sp.y = -graphic->GetCenter().y * scale + offY; sp.y = -graphic->GetCenter().y * scale + offY;
@ -479,13 +485,17 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD
comp->SetRefDes( refdes ); comp->SetRefDes( refdes );
if( top ) if( top )
{
comp->SetPosition( aFootprint->GetPosition().x * scale + dx, comp->SetPosition( aFootprint->GetPosition().x * scale + dx,
-aFootprint->GetPosition().y * scale + dy, -aFootprint->GetPosition().y * scale + dy,
rotz, IDF3::LYR_TOP ); rotz, IDF3::LYR_TOP );
}
else else
{
comp->SetPosition( aFootprint->GetPosition().x * scale + dx, comp->SetPosition( aFootprint->GetPosition().x * scale + dx,
-aFootprint->GetPosition().y * scale + dy, -aFootprint->GetPosition().y * scale + dy,
rotz, IDF3::LYR_BOTTOM ); rotz, IDF3::LYR_BOTTOM );
}
comp->SetPlacement( IDF3::PS_ECAD ); comp->SetPlacement( IDF3::PS_ECAD );
@ -500,13 +510,17 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD
{ {
// place the item // place the item
if( top ) if( top )
{
comp->SetPosition( aFootprint->GetPosition().x * scale + dx, comp->SetPosition( aFootprint->GetPosition().x * scale + dx,
-aFootprint->GetPosition().y * scale + dy, -aFootprint->GetPosition().y * scale + dy,
rotz, IDF3::LYR_TOP ); rotz, IDF3::LYR_TOP );
}
else else
{
comp->SetPosition( aFootprint->GetPosition().x * scale + dx, comp->SetPosition( aFootprint->GetPosition().x * scale + dx,
-aFootprint->GetPosition().y * scale + dy, -aFootprint->GetPosition().y * scale + dy,
rotz, IDF3::LYR_BOTTOM ); rotz, IDF3::LYR_BOTTOM );
}
comp->SetPlacement( IDF3::PS_ECAD ); comp->SetPlacement( IDF3::PS_ECAD );

View File

@ -341,15 +341,15 @@ void EXCELLON_WRITER::SetFormat( bool aMetric,
if( aRightDigits <= 0 ) if( aRightDigits <= 0 )
aRightDigits = m_unitsMetric ? 3 : 4; aRightDigits = m_unitsMetric ? 3 : 4;
m_precision.m_lhs = aLeftDigits; m_precision.m_Lhs = aLeftDigits;
m_precision.m_rhs = aRightDigits; m_precision.m_Rhs = aRightDigits;
} }
void EXCELLON_WRITER::writeCoordinates( char* aLine, double aCoordX, double aCoordY ) void EXCELLON_WRITER::writeCoordinates( char* aLine, double aCoordX, double aCoordY )
{ {
wxString xs, ys; wxString xs, ys;
int xpad = m_precision.m_lhs + m_precision.m_rhs; int xpad = m_precision.m_Lhs + m_precision.m_Rhs;
int ypad = xpad; int ypad = xpad;
switch( m_zeroFormat ) switch( m_zeroFormat )
@ -393,7 +393,7 @@ void EXCELLON_WRITER::writeCoordinates( char* aLine, double aCoordX, double aCoo
break; break;
case SUPPRESS_LEADING: case SUPPRESS_LEADING:
for( int i = 0; i< m_precision.m_rhs; i++ ) for( int i = 0; i< m_precision.m_Rhs; i++ )
{ {
aCoordX *= 10; aCoordY *= 10; aCoordX *= 10; aCoordY *= 10;
} }
@ -403,7 +403,7 @@ void EXCELLON_WRITER::writeCoordinates( char* aLine, double aCoordX, double aCoo
case SUPPRESS_TRAILING: case SUPPRESS_TRAILING:
{ {
for( int i = 0; i < m_precision.m_rhs; i++ ) for( int i = 0; i < m_precision.m_Rhs; i++ )
{ {
aCoordX *= 10; aCoordX *= 10;
aCoordY *= 10; aCoordY *= 10;
@ -433,7 +433,7 @@ void EXCELLON_WRITER::writeCoordinates( char* aLine, double aCoordX, double aCoo
} }
case KEEP_ZEROS: case KEEP_ZEROS:
for( int i = 0; i< m_precision.m_rhs; i++ ) for( int i = 0; i< m_precision.m_Rhs; i++ )
{ {
aCoordX *= 10; aCoordY *= 10; aCoordX *= 10; aCoordY *= 10;
} }

View File

@ -44,11 +44,11 @@ class OUTPUTFORMATTER;
class EXCELLON_WRITER: public GENDRILL_WRITER_BASE class EXCELLON_WRITER: public GENDRILL_WRITER_BASE
{ {
private: private:
FILE* m_file; // The output file FILE* m_file; // The output file
bool m_minimalHeader; // True to use minimal header bool m_minimalHeader; // True to use minimal header
bool m_mirror; bool m_mirror;
bool m_useRouteModeForOval; // True to use a route command for oval holes bool m_useRouteModeForOval; // True to use a route command for oval holes
// False to use a G85 canned mode for oval holes // False to use a G85 canned mode for oval holes
public: public:
@ -113,8 +113,7 @@ public:
* @param aGenMap = true to generate a drill map file * @param aGenMap = true to generate a drill map file
* @param aReporter = a REPORTER to return activity or any message (can be NULL) * @param aReporter = a REPORTER to return activity or any message (can be NULL)
*/ */
void CreateDrillandMapFilesSet( const wxString& aPlotDirectory, void CreateDrillandMapFilesSet( const wxString& aPlotDirectory, bool aGenDrill, bool aGenMap,
bool aGenDrill, bool aGenMap,
REPORTER * aReporter = NULL ); REPORTER * aReporter = NULL );
@ -125,8 +124,7 @@ private:
* @param aFile = an opened file to write to will be closed by CreateDrillFile * @param aFile = an opened file to write to will be closed by CreateDrillFile
* @return hole count * @return hole count
*/ */
int createDrillFile( FILE * aFile, DRILL_LAYER_PAIR aLayerPair, int createDrillFile( FILE * aFile, DRILL_LAYER_PAIR aLayerPair, bool aGenerateNPTH_list );
bool aGenerateNPTH_list );
/* Print the DRILL file header. The full header is somethink like: /* Print the DRILL file header. The full header is somethink like:
@ -139,8 +137,7 @@ private:
* FMAT,2 * FMAT,2
* INCH,TZ * INCH,TZ
*/ */
void writeEXCELLONHeader( DRILL_LAYER_PAIR aLayerPair, void writeEXCELLONHeader( DRILL_LAYER_PAIR aLayerPair, bool aGenerateNPTH_list);
bool aGenerateNPTH_list);
void writeEXCELLONEndOfFile(); void writeEXCELLONEndOfFile();

View File

@ -95,13 +95,13 @@ public:
class DRILL_PRECISION class DRILL_PRECISION
{ {
public: public:
int m_lhs; // Left digit number (integer value of coordinates) int m_Lhs; // Left digit number (integer value of coordinates)
int m_rhs; // Right digit number (decimal value of coordinates) int m_Rhs; // Right digit number (decimal value of coordinates)
public: public:
DRILL_PRECISION( int l = 2, int r = 4 ) DRILL_PRECISION( int l = 2, int r = 4 )
{ {
m_lhs = l; m_rhs = r; m_Lhs = l; m_Rhs = r;
} }
@ -109,7 +109,7 @@ public:
{ {
wxString text; wxString text;
text << m_lhs << wxT( ":" ) << m_rhs; text << m_Lhs << wxT( ":" ) << m_Rhs;
return text; return text;
} }
}; };
@ -208,8 +208,7 @@ public:
* @param aPlotDirectory = the output folder * @param aPlotDirectory = the output folder
* @param aReporter = a REPORTER to return activity or any message (can be NULL) * @param aReporter = a REPORTER to return activity or any message (can be NULL)
*/ */
void CreateMapFilesSet( const wxString& aPlotDirectory, void CreateMapFilesSet( const wxString& aPlotDirectory, REPORTER* aReporter = NULL );
REPORTER* aReporter = NULL );
/** /**
* Function GenDrillReportFile * Function GenDrillReportFile

View File

@ -275,8 +275,8 @@ void GERBER_WRITER::SetFormat( int aRightDigits )
m_conversionUnits = 1.0 / IU_PER_MM; // Gerber units = mm m_conversionUnits = 1.0 / IU_PER_MM; // Gerber units = mm
// Set precison (unit is mm). // Set precison (unit is mm).
m_precision.m_lhs = 4; m_precision.m_Lhs = 4;
m_precision.m_rhs = aRightDigits == 6 ? 6 : 5; m_precision.m_Rhs = aRightDigits == 6 ? 6 : 5;
} }

View File

@ -44,10 +44,7 @@
PLACEFILE_GERBER_WRITER::PLACEFILE_GERBER_WRITER( BOARD* aPcb ) PLACEFILE_GERBER_WRITER::PLACEFILE_GERBER_WRITER( BOARD* aPcb )
{ {
m_pcb = aPcb; m_pcb = aPcb;
/* Set conversion scale depending on drill file units */
m_conversionUnits = 1.0 / IU_PER_MM; // Gerber units = mm
m_forceSmdItems = false;
m_plotPad1Marker = true; // Place a marker to pin 1 (or A1) position m_plotPad1Marker = true; // Place a marker to pin 1 (or A1) position
m_plotOtherPadsMarker = true; // Place a marker to other pins position m_plotOtherPadsMarker = true; // Place a marker to other pins position
m_layer = PCB_LAYER_ID::UNDEFINED_LAYER; // No layer set m_layer = PCB_LAYER_ID::UNDEFINED_LAYER; // No layer set

View File

@ -64,8 +64,7 @@ public:
* @param aIncludeBrdEdges = true to include board outlines * @param aIncludeBrdEdges = true to include board outlines
* @return component count, or -1 if the file cannot be created * @return component count, or -1 if the file cannot be created
*/ */
int CreatePlaceFile( wxString& aFullFilename, PCB_LAYER_ID aLayer, int CreatePlaceFile( wxString& aFullFilename, PCB_LAYER_ID aLayer, bool aIncludeBrdEdges );
bool aIncludeBrdEdges );
/** /**
* @return a filename which identify the drill file function. * @return a filename which identify the drill file function.
@ -77,26 +76,22 @@ public:
PCB_LAYER_ID aLayer ) const; PCB_LAYER_ID aLayer ) const;
private: private:
BOARD* m_pcb; BOARD* m_pcb;
/// The board layer currently used (typically F_Cu or B_Cu) PCB_LAYER_ID m_layer; // The board layer currently used (typically F_Cu or B_Cu)
PCB_LAYER_ID m_layer; wxPoint m_offset; // Drill offset coordinates
double m_conversionUnits; // scaling factor to convert the board unites to
// Excellon/Gerber units (i.e inches or mm)
wxPoint m_offset; // Drill offset coordinates
bool m_forceSmdItems;
// True to plot a flashed marker shape at pad 1 position
bool m_plotPad1Marker;
// True to plot a marker shape at other pads position
// This is a flashed 0 sized round pad
bool m_plotOtherPadsMarker;
bool m_plotPad1Marker; // True to plot a flashed marker shape at pad 1 position
bool m_plotOtherPadsMarker; // True to plot a marker shape at other pads position
// This is a flashed 0 sized round pad
/** convert a kicad footprint orientation to gerber rotation /**
* both are in degrees * convert a kicad footprint orientation to gerber rotation
* both are in degrees
*/ */
double mapRotationAngle( double aAngle ); double mapRotationAngle( double aAngle );
/** Find the pad(s) 1 (or pad "A1") of a footprint /**
* Find the pad(s) 1 (or pad "A1") of a footprint
* Usefull to plot a marker at this (these) position(s) * Usefull to plot a marker at this (these) position(s)
* @param aPadList is the list to fill * @param aPadList is the list to fill
* @param aFootprint is the footprint to test * @param aFootprint is the footprint to test

View File

@ -41,8 +41,10 @@ public:
class IMPORTED_LINE : public IMPORTED_SHAPE class IMPORTED_LINE : public IMPORTED_SHAPE
{ {
public: public:
IMPORTED_LINE( const VECTOR2D& aStart, const VECTOR2D& aEnd, double aWidth ) IMPORTED_LINE( const VECTOR2D& aStart, const VECTOR2D& aEnd, double aWidth ) :
: m_start( aStart ), m_end( aEnd ), m_width( aWidth ) m_start( aStart ),
m_end( aEnd ),
m_width( aWidth )
{ {
} }
@ -54,15 +56,17 @@ public:
private: private:
const VECTOR2D m_start; const VECTOR2D m_start;
const VECTOR2D m_end; const VECTOR2D m_end;
double m_width; double m_width;
}; };
class IMPORTED_CIRCLE : public IMPORTED_SHAPE class IMPORTED_CIRCLE : public IMPORTED_SHAPE
{ {
public: public:
IMPORTED_CIRCLE( const VECTOR2D& aCenter, double aRadius, double aWidth ) IMPORTED_CIRCLE( const VECTOR2D& aCenter, double aRadius, double aWidth ) :
: m_center( aCenter ), m_radius( aRadius ), m_width( aWidth ) m_center( aCenter ),
m_radius( aRadius ),
m_width( aWidth )
{ {
} }
@ -73,16 +77,19 @@ public:
private: private:
const VECTOR2D m_center; const VECTOR2D m_center;
double m_radius; double m_radius;
double m_width; double m_width;
}; };
class IMPORTED_ARC : public IMPORTED_SHAPE class IMPORTED_ARC : public IMPORTED_SHAPE
{ {
public: public:
IMPORTED_ARC( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle, double aWidth ) IMPORTED_ARC( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle, double aWidth ) :
: m_center( aCenter ), m_start( aStart ), m_angle( aAngle ), m_width( aWidth ) m_center( aCenter ),
m_start( aStart ),
m_angle( aAngle ),
m_width( aWidth )
{ {
} }
@ -94,16 +101,17 @@ public:
private: private:
const VECTOR2D m_center; const VECTOR2D m_center;
const VECTOR2D m_start; const VECTOR2D m_start;
double m_angle; double m_angle;
double m_width; double m_width;
}; };
class IMPORTED_POLYGON : public IMPORTED_SHAPE class IMPORTED_POLYGON : public IMPORTED_SHAPE
{ {
public: public:
IMPORTED_POLYGON( const std::vector< VECTOR2D >& aVertices, double aWidth ) IMPORTED_POLYGON( const std::vector< VECTOR2D >& aVertices, double aWidth ) :
: m_vertices( aVertices ), m_width( aWidth ) m_vertices( aVertices ),
m_width( aWidth )
{ {
} }
@ -113,21 +121,25 @@ public:
} }
private: private:
const std::vector< VECTOR2D > m_vertices; const std::vector<VECTOR2D> m_vertices;
double m_width; double m_width;
}; };
class IMPORTED_TEXT : public IMPORTED_SHAPE class IMPORTED_TEXT : public IMPORTED_SHAPE
{ {
public: public:
IMPORTED_TEXT( const VECTOR2D& aOrigin, const wxString& aText, IMPORTED_TEXT( const VECTOR2D& aOrigin, const wxString& aText, double aHeight, double aWidth,
double aHeight, double aWidth, double aThickness, double aOrientation, double aThickness, double aOrientation, EDA_TEXT_HJUSTIFY_T aHJustify,
EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) EDA_TEXT_VJUSTIFY_T aVJustify ) :
: m_origin( aOrigin ), m_text( aText ), m_origin( aOrigin ),
m_height( aHeight ), m_width( aWidth ), m_thickness( aThickness ), m_text( aText ),
m_orientation( aOrientation ), m_height( aHeight ),
m_hJustify( aHJustify ), m_vJustify( aVJustify ) m_width( aWidth ),
m_thickness( aThickness ),
m_orientation( aOrientation ),
m_hJustify( aHJustify ),
m_vJustify( aVJustify )
{ {
} }
@ -138,12 +150,12 @@ public:
} }
private: private:
const VECTOR2D m_origin; const VECTOR2D m_origin;
const wxString m_text; const wxString m_text;
double m_height; double m_height;
double m_width; double m_width;
double m_thickness; double m_thickness;
double m_orientation; double m_orientation;
EDA_TEXT_HJUSTIFY_T m_hJustify; EDA_TEXT_HJUSTIFY_T m_hJustify;
EDA_TEXT_VJUSTIFY_T m_vJustify; EDA_TEXT_VJUSTIFY_T m_vJustify;
}; };
@ -153,9 +165,12 @@ class IMPORTED_SPLINE : public IMPORTED_SHAPE
{ {
public: public:
IMPORTED_SPLINE( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1, IMPORTED_SPLINE( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,
const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd, double aWidth ) const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd, double aWidth ) :
: m_start( aStart ), m_bezierControl1( aBezierControl1 ), m_start( aStart ),
m_bezierControl2( aBezierControl2 ), m_end( aEnd ), m_width( aWidth ) m_bezierControl1( aBezierControl1 ),
m_bezierControl2( aBezierControl2 ),
m_end( aEnd ),
m_width( aWidth )
{ {
} }
@ -169,7 +184,7 @@ private:
const VECTOR2D m_bezierControl1; const VECTOR2D m_bezierControl1;
const VECTOR2D m_bezierControl2; const VECTOR2D m_bezierControl2;
const VECTOR2D m_end; const VECTOR2D m_end;
double m_width; double m_width;
}; };

View File

@ -366,20 +366,20 @@ FOOTPRINT* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN&
auto pt = aInductorPattern.m_End - aInductorPattern.m_Start; auto pt = aInductorPattern.m_End - aInductorPattern.m_Start;
int min_len = KiROUND( EuclideanNorm( pt ) ); int min_len = KiROUND( EuclideanNorm( pt ) );
aInductorPattern.m_length = min_len; aInductorPattern.m_Length = min_len;
// Enter the desired length. // Enter the desired length.
msg = StringFromValue( editFrame.GetUserUnits(), aInductorPattern.m_length ); msg = StringFromValue( editFrame.GetUserUnits(), aInductorPattern.m_Length );
WX_TEXT_ENTRY_DIALOG dlg( &editFrame, _( "Length of Trace:" ), wxEmptyString, msg ); WX_TEXT_ENTRY_DIALOG dlg( &editFrame, _( "Length of Trace:" ), wxEmptyString, msg );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return nullptr; // canceled by user return nullptr; // canceled by user
msg = dlg.GetValue(); msg = dlg.GetValue();
aInductorPattern.m_length = ValueFromString( editFrame.GetUserUnits(), msg ); aInductorPattern.m_Length = ValueFromString( editFrame.GetUserUnits(), msg );
// Control values (ii = minimum length) // Control values (ii = minimum length)
if( aInductorPattern.m_length < min_len ) if( aInductorPattern.m_Length < min_len )
{ {
aErrorMessage = _( "Requested length < minimum length" ); aErrorMessage = _( "Requested length < minimum length" );
return nullptr; return nullptr;
@ -388,7 +388,7 @@ FOOTPRINT* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN&
// Calculate the elements. // Calculate the elements.
std::vector <wxPoint> buffer; std::vector <wxPoint> buffer;
const INDUCTOR_S_SHAPE_RESULT res = BuildCornersList_S_Shape( buffer, aInductorPattern.m_Start, const INDUCTOR_S_SHAPE_RESULT res = BuildCornersList_S_Shape( buffer, aInductorPattern.m_Start,
aInductorPattern.m_End, aInductorPattern.m_length, aInductorPattern.m_Width ); aInductorPattern.m_End, aInductorPattern.m_Length, aInductorPattern.m_Width );
switch( res ) switch( res )
{ {

View File

@ -45,7 +45,7 @@ struct MICROWAVE_INDUCTOR_PATTERN
public: public:
wxPoint m_Start; wxPoint m_Start;
wxPoint m_End; wxPoint m_End;
int m_length; // full length trace. int m_Length; // full length trace.
int m_Width; // Trace width. int m_Width; // Trace width.
}; };