Avoid C-style array member init (illegal in C++)

This is not part of the C++ language, and only supported in some compilers.
This commit is contained in:
Simon Richter 2017-12-06 03:42:37 +01:00 committed by Wayne Stambaugh
parent eaa31dc11b
commit 227afe77c0
3 changed files with 28 additions and 20 deletions

View File

@ -94,18 +94,20 @@ static const struct
{ "YELLOW4", 2 }
};
/**
* Line types in the boilerplate DXF header. The
* element indices correspond to the eeschema line
* types.
*/
static const char *dxf_lines[] =
static const char* getDXFLineType( PlotDashType aType )
{
[ PLOTDASHTYPE_SOLID ] = "CONTINUOUS",
[ PLOTDASHTYPE_DASH ] = "DASHED",
[ PLOTDASHTYPE_DOT ] = "DOTTED",
[ PLOTDASHTYPE_DASHDOT ] = "DASHDOT"
};
switch( aType )
{
case PLOTDASHTYPE_SOLID: return "CONTINUOUS";
case PLOTDASHTYPE_DASH: return "DASHED";
case PLOTDASHTYPE_DOT: return "DOTTED";
case PLOTDASHTYPE_DASHDOT: return "DASHDOT";
}
wxFAIL_MSG( "Unhandled PlotDashType" );
return "CONTINUOUS";
}
// A helper function to create a color name acceptable in DXF files
@ -565,7 +567,7 @@ void DXF_PLOTTER::PenTo( const wxPoint& pos, char plume )
wxASSERT( m_currentLineType >= 0 && m_currentLineType < 4 );
// DXF LINE
wxString cname = getDXFColorName( m_currentColor );
const char *lname = dxf_lines[ m_currentLineType ];
const char *lname = getDXFLineType( (PlotDashType) m_currentLineType );
fprintf( outputFile, "0\nLINE\n8\n%s\n6\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n",
TO_UTF8( cname ), lname,
pen_lastpos_dev.x, pen_lastpos_dev.y, pos_dev.x, pos_dev.y );

View File

@ -42,13 +42,20 @@
#include <dialogs/dialog_edit_line_style.h>
const enum wxPenStyle SCH_LINE::PenStyle[] =
static wxPenStyle getwxPenStyle( PlotDashType aType )
{
[PLOTDASHTYPE_SOLID] = wxPENSTYLE_SOLID,
[PLOTDASHTYPE_DASH] = wxPENSTYLE_SHORT_DASH,
[PLOTDASHTYPE_DOT] = wxPENSTYLE_DOT,
[PLOTDASHTYPE_DASHDOT] = wxPENSTYLE_DOT_DASH
};
switch( aType )
{
case PLOTDASHTYPE_SOLID: return wxPENSTYLE_SOLID;
case PLOTDASHTYPE_DASH: return wxPENSTYLE_SHORT_DASH;
case PLOTDASHTYPE_DOT: return wxPENSTYLE_DOT;
case PLOTDASHTYPE_DASHDOT: return wxPENSTYLE_DOT_DASH;
}
wxFAIL_MSG( "Unhandled PlotDashType" );
return wxPENSTYLE_SOLID;
}
SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) :
@ -321,7 +328,7 @@ void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
end += offset;
GRLine( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y, width, color,
PenStyle[ GetLineStyle() ] );
getwxPenStyle( (PlotDashType) GetLineStyle() ) );
if( m_startIsDangling )
DrawDanglingSymbol( panel, DC, start, color );

View File

@ -85,7 +85,6 @@ enum PlotDashType {
PLOTDASHTYPE_DASH,
PLOTDASHTYPE_DOT,
PLOTDASHTYPE_DASHDOT,
PLOTDASHTYPE_COUNT,
};
/**