Better board-edge error reporting.

Fixes https://gitlab.com/kicad/code/kicad/issues/4950
This commit is contained in:
Jeff Young 2020-08-17 21:07:27 +01:00
parent 01eb8ad032
commit 66ff16dd3d
6 changed files with 25 additions and 16 deletions

View File

@ -426,8 +426,10 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
if( aStatusReporter )
aStatusReporter->Report( _( "Build board body" ) );
if( !createBoardPolygon() )
aWarningReporter->Report( _( "Board outline is not closed" ), RPT_SEVERITY_WARNING );
wxString msg;
if( !createBoardPolygon( &msg ) )
aWarningReporter->Report( _( "Board outline is not closed: " ) + msg, RPT_SEVERITY_WARNING );
else
aWarningReporter->Report( wxEmptyString );
@ -454,13 +456,13 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
}
bool BOARD_ADAPTER::createBoardPolygon()
bool BOARD_ADAPTER::createBoardPolygon( wxString* aErrorMsg )
{
m_board_poly.RemoveAllContours();
wxString errmsg;
return m_board->GetBoardPolygonOutlines( m_board_poly, &errmsg );
return m_board->GetBoardPolygonOutlines( m_board_poly, aErrorMsg );
}

View File

@ -569,7 +569,7 @@ class BOARD_ADAPTER
*
* @return false if the outline could not be created
*/
bool createBoardPolygon();
bool createBoardPolygon( wxString* aErrorMsg );
void createLayers( REPORTER* aStatusReporter );
void destroyLayers();

View File

@ -199,6 +199,9 @@ void INFOBAR_REPORTER::Finalize()
case RPT_SEVERITY_IGNORE: icon = wxICON_INFORMATION; break;
}
if( m_message.EndsWith( "\n" ) )
m_message = m_message.Left( m_message.Length() - 1 );
if( HasMessage() )
m_infoBar->QueueShowMessage( m_message, icon );
else

View File

@ -1813,11 +1813,11 @@ extern bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
wxPoint* aErrorLocation = nullptr );
bool BOARD::GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines, wxString* aErrorText, wxPoint* aErrorLocation )
bool BOARD::GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines, wxString* aErrorText,
wxPoint* aErrorLocation )
{
bool success = BuildBoardPolygonOutlines( this, aOutlines, aErrorText,
GetDesignSettings().m_MaxError, aErrorLocation );
GetDesignSettings().m_MaxError, aErrorLocation );
// Make polygon strictly simple to avoid issues (especially in 3D viewer)
aOutlines.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );

View File

@ -621,8 +621,8 @@ public:
*
* @return true if success, false if a contour is not valid
*/
bool GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines,
wxString* aErrorText = nullptr, wxPoint* aErrorLocation = nullptr );
bool GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines, wxString* aErrorText = nullptr,
wxPoint* aErrorLocation = nullptr );
/**
* Function ConvertBrdLayerToPolygonalContours

View File

@ -488,9 +488,9 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
{
if( aErrorText )
{
msg.Printf( _( "Unable to find segment with an endpoint of (%s, %s)." ),
StringFromValue( EDA_UNITS::MILLIMETRES, prevPt.x, true ),
StringFromValue( EDA_UNITS::MILLIMETRES, prevPt.y, true ) );
msg.Printf( _( "Unable to find edge with an endpoint of (%s, %s)." ),
StringFromValue( EDA_UNITS::MILLIMETRES, prevPt.x, true ),
StringFromValue( EDA_UNITS::MILLIMETRES, prevPt.y, true ) );
*aErrorText << msg << "\n";
}
@ -694,7 +694,7 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
{
if( aErrorText )
{
msg.Printf( _( "Unable to find segment with an endpoint of (%s, %s)." ),
msg.Printf( _( "Unable to find edge with an endpoint of (%s, %s)." ),
StringFromValue( EDA_UNITS::MILLIMETRES, prevPt.x, true ),
StringFromValue( EDA_UNITS::MILLIMETRES, prevPt.y, true ) );
@ -758,8 +758,8 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
* Any closed outline inside the main outline is a hole
* All contours should be closed, i.e. valid closed polygon vertices
*/
bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
wxString* aErrorText, unsigned int aTolerance, wxPoint* aErrorLocation )
bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines, wxString* aErrorText,
unsigned int aTolerance, wxPoint* aErrorLocation )
{
PCB_TYPE_COLLECTOR items;
bool success = false;
@ -783,6 +783,10 @@ bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
success = ConvertOutlineToPolygon( segList, aOutlines, aErrorText, aTolerance,
aErrorLocation );
}
else
{
*aErrorText = _( "No edges found on Edge.Cuts layer." );
}
if( !success || !aOutlines.OutlineCount() )
{