Improve slightly confusing error message.

This commit is contained in:
Jeff Young 2018-10-11 15:31:35 +01:00
parent 4904ece0b5
commit d9bf1550e4
2 changed files with 19 additions and 28 deletions

View File

@ -1475,18 +1475,19 @@ bool MODULE::BuildPolyCourtyard()
wxString error_msg; wxString error_msg;
bool success = ConvertOutlineToPolygon( list_front, m_poly_courtyard_front, bool success = ConvertOutlineToPolygon( list_front, m_poly_courtyard_front,
&error_msg, Millimeter2iu( 0.05 ) ); &error_msg, (unsigned) Millimeter2iu( 0.05 ) );
if( success ) if( success )
{ {
success = ConvertOutlineToPolygon( list_back, m_poly_courtyard_back, success = ConvertOutlineToPolygon( list_back, m_poly_courtyard_back,
&error_msg, Millimeter2iu( 0.05 ) ); &error_msg, (unsigned) Millimeter2iu( 0.05 ) );
} }
if( !error_msg.IsEmpty() ) if( !error_msg.IsEmpty() )
{ {
error_msg.Prepend( GetReference() + ": " ); wxLogMessage( wxString::Format( _( "Processing courtyard of \"%s\": %s" ),
wxLogMessage( error_msg ); GetChars( GetFPID().Format() ),
error_msg) );
} }
return success; return success;

View File

@ -179,7 +179,7 @@ static DRAWSEGMENT* findPoint( const wxPoint& aPoint, std::vector< DRAWSEGMENT*
* @param aErrorText is a wxString to return error message. * @param aErrorText is a wxString to return error message.
*/ */
bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SET& aPolygons, bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SET& aPolygons,
wxString* aErrorText, unsigned int aTolerance ) wxString* aErrorText, unsigned int aTolerance )
{ {
if( aSegList.size() == 0 ) if( aSegList.size() == 0 )
return true; return true;
@ -393,14 +393,12 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
if( reverse ) if( reverse )
{ {
for( int jj = graphic->GetBezierPoints().size()-1; for( int jj = graphic->GetBezierPoints().size()-1; jj >= 0; jj-- )
jj >= 0; jj-- )
aPolygons.Append( graphic->GetBezierPoints()[jj] ); aPolygons.Append( graphic->GetBezierPoints()[jj] );
} }
else else
{ {
for( unsigned int jj = 0; for( size_t jj = 0; jj < graphic->GetBezierPoints().size(); jj++ )
jj < graphic->GetBezierPoints().size(); jj++ )
aPolygons.Append( graphic->GetBezierPoints()[jj] ); aPolygons.Append( graphic->GetBezierPoints()[jj] );
} }
@ -411,7 +409,7 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
default: default:
if( aErrorText ) if( aErrorText )
{ {
msg.Printf( _( "Unsupported DRAWSEGMENT type %s" ), msg.Printf( _( "Unsupported DRAWSEGMENT type %s." ),
GetChars( BOARD_ITEM::ShowShape( graphic->GetShape() ) ) ); GetChars( BOARD_ITEM::ShowShape( graphic->GetShape() ) ) );
*aErrorText << msg << "\n"; *aErrorText << msg << "\n";
@ -438,12 +436,9 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
{ {
if( aErrorText ) if( aErrorText )
{ {
msg.Printf( msg.Printf( _( "Unable to find segment with an endpoint of (%s, %s)." ),
_( "Unable to find the next boundary segment with an endpoint of (%s mm, %s mm). " StringFromValue( MILLIMETRES, prevPt.x, true ),
"graphic outline must form a contiguous, closed polygon." ), StringFromValue( MILLIMETRES, prevPt.y, true ) );
GetChars( FROM_UTF8( BOARD_ITEM::FormatInternalUnits( prevPt.x ).c_str() ) ),
GetChars( FROM_UTF8( BOARD_ITEM::FormatInternalUnits( prevPt.y ).c_str() ) )
);
*aErrorText << msg << "\n"; *aErrorText << msg << "\n";
} }
@ -577,14 +572,12 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
if( reverse ) if( reverse )
{ {
for( int jj = graphic->GetBezierPoints().size()-1; for( int jj = graphic->GetBezierPoints().size()-1; jj >= 0; jj-- )
jj >= 0; jj-- )
aPolygons.Append( graphic->GetBezierPoints()[jj], -1, hole ); aPolygons.Append( graphic->GetBezierPoints()[jj], -1, hole );
} }
else else
{ {
for( unsigned int jj = 0; for( size_t jj = 0; jj < graphic->GetBezierPoints().size(); jj++ )
jj < graphic->GetBezierPoints().size(); jj++ )
aPolygons.Append( graphic->GetBezierPoints()[jj], -1, hole ); aPolygons.Append( graphic->GetBezierPoints()[jj], -1, hole );
} }
@ -595,8 +588,8 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
default: default:
if( aErrorText ) if( aErrorText )
{ {
msg.Printf( _( "Unsupported DRAWSEGMENT type %s" ), msg.Printf( _( "Unsupported DRAWSEGMENT type %s." ),
GetChars( BOARD_ITEM::ShowShape( graphic->GetShape() ) ) ); BOARD_ITEM::ShowShape( graphic->GetShape() ) );
*aErrorText << msg << "\n"; *aErrorText << msg << "\n";
} }
@ -622,12 +615,9 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
{ {
if( aErrorText ) if( aErrorText )
{ {
msg.Printf( msg.Printf( _( "Unable to find segment with an endpoint of (%s, %s)." ),
_( "Unable to find the next graphic segment with an endpoint of (%s mm, %s mm).\n" StringFromValue( MILLIMETRES, prevPt.x, true ),
"Edit graphics, making them contiguous polygons each." ), StringFromValue( MILLIMETRES, prevPt.y, true ) );
GetChars( FROM_UTF8( BOARD_ITEM::FormatInternalUnits( prevPt.x ).c_str() ) ),
GetChars( FROM_UTF8( BOARD_ITEM::FormatInternalUnits( prevPt.y ).c_str() ) )
);
*aErrorText << msg << "\n"; *aErrorText << msg << "\n";
} }