diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index 344104c186..bb539456e7 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -368,6 +369,18 @@ void BOARD_ADAPTER::createNewPadWithClearance( const D_PAD* aPad, } break; + case SH_RECT: + { + SHAPE_RECT* rect = (SHAPE_RECT*) shape.get(); + + poly.NewOutline(); + poly.Append( rect->GetPosition() ); + poly.Append( rect->GetPosition().x + rect->GetSize().x, rect->GetPosition().y ); + poly.Append( rect->GetPosition() + rect->GetSize() ); + poly.Append( rect->GetPosition().x, rect->GetPosition().y + rect->GetSize().y ); + } + break; + case SH_SIMPLE: poly.AddOutline( static_cast( shape.get() )->Vertices() ); break; @@ -377,7 +390,8 @@ void BOARD_ADAPTER::createNewPadWithClearance( const D_PAD* aPad, break; default: - wxFAIL_MSG( "BOARD_ADAPTER::createNewPadWithClearance unimplemented shape" ); + wxFAIL_MSG( "BOARD_ADAPTER::createNewPadWithClearance no implementation for " + + SHAPE_TYPE_asString( shape->Type() ) ); break; } } @@ -695,6 +709,8 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const DRAWSEGMENT* aDrawSe break; default: + wxFAIL_MSG( "BOARD_ADAPTER::AddShapeWithClearanceToContainer no implementation for " + + STROKE_T_asString( aDrawSegment->GetShape() ) ); break; } } diff --git a/include/class_board_item.h b/include/class_board_item.h index 48e814e91d..158d4f3732 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -59,6 +59,21 @@ enum STROKE_T S_LAST ///< last value for this list }; +static inline wxString STROKE_T_asString( STROKE_T a ) +{ + switch( a ) + { + case S_SEGMENT: return "S_SEGMENT"; + case S_RECT: return "S_RECT"; + case S_ARC: return "S_ARC"; + case S_CIRCLE: return "S_CIRCLE"; + case S_POLYGON: return "S_POLYGON"; + case S_CURVE: return "S_CURVE"; + case S_LAST: return "S_LAST"; // Synthetic value, but if we come across it we're + // going to want to know. + } +}; + /** * BOARD_ITEM diff --git a/include/pad_shapes.h b/include/pad_shapes.h index c435a12f57..4e1348b6b7 100644 --- a/include/pad_shapes.h +++ b/include/pad_shapes.h @@ -40,6 +40,21 @@ enum PAD_SHAPE_T // (thick segments, circles, arcs, polygons }; +static inline wxString PAD_SHAPE_T_asString( PAD_SHAPE_T a ) +{ + switch( a ) + { + case PAD_SHAPE_CIRCLE: return "PAD_SHAPE_CIRCLE"; + case PAD_SHAPE_RECT: return "PAD_SHAPE_RECT"; + case PAD_SHAPE_OVAL: return "PAD_SHAPE_OVAL"; + case PAD_SHAPE_TRAPEZOID: return "PAD_SHAPE_TRAPEZOID"; + case PAD_SHAPE_ROUNDRECT: return "PAD_SHAPE_ROUNDRECT"; + case PAD_SHAPE_CHAMFERED_RECT: return "PAD_SHAPE_CHAMFERED_RECT"; + case PAD_SHAPE_CUSTOM: return "PAD_SHAPE_CUSTOM"; + } +}; + + /** * Enum PAD_DRILL_SHAPE_T * is the set of pad drill shapes, used with D_PAD::{Set,Get}DrillShape() diff --git a/libs/kimath/include/geometry/shape.h b/libs/kimath/include/geometry/shape.h index aa9492adb6..09b4894ec0 100644 --- a/libs/kimath/include/geometry/shape.h +++ b/libs/kimath/include/geometry/shape.h @@ -25,12 +25,8 @@ #ifndef __SHAPE_H #define __SHAPE_H -#include // for assert #include -#include // for NULL - #include - #include #include @@ -52,6 +48,22 @@ enum SHAPE_TYPE SH_ARC ///> circular arc }; +static inline wxString SHAPE_TYPE_asString( SHAPE_TYPE a ) +{ + switch( a ) + { + case SH_RECT: return "SH_RECT"; + case SH_SEGMENT: return "SH_SEGMENT"; + case SH_LINE_CHAIN: return "SH_LINE_CHAIN"; + case SH_CIRCLE: return "SH_CIRCLE"; + case SH_SIMPLE: return "SH_SIMPLE"; + case SH_POLY_SET: return "SH_POLY_SET"; + case SH_COMPOUND: return "SH_COMPOUND"; + case SH_ARC: return "SH_ARC"; + } +} + + /** * SHAPE * diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index cb3c355fa4..3dcc9f5698 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -468,6 +468,8 @@ void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerB break; default: + wxFAIL_MSG( "DRAWSEGMENT::TransformShapeWithClearanceToPolygon no implementation for " + + STROKE_T_asString( m_Shape ) ); break; } } @@ -628,6 +630,11 @@ void D_PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, aCornerBuffer.Append( outline ); } break; + + default: + wxFAIL_MSG( "D_PAD::TransformShapeWithClearanceToPolygon no implementation for " + + PAD_SHAPE_T_asString( GetShape() ) ); + break; } } diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 130d0b62c7..1865b0d430 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -219,9 +219,7 @@ void DRAWSEGMENT::Rotate( const wxPoint& aRotCentre, double aAngle ) break; default: - // un-handled edge transform - wxASSERT_MSG( false, wxT( "DRAWSEGMENT::Rotate not implemented for " - + ShowShape( m_Shape ) ) ); + wxFAIL_MSG( "DRAWSEGMENT::Rotate not implemented for " + STROKE_T_asString( m_Shape ) ); break; } } @@ -270,7 +268,13 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) } break; + case S_SEGMENT: + case S_RECT: + case S_CIRCLE: + break; + default: + wxFAIL_MSG( "DRAWSEGMENT::Flip not implemented for " + STROKE_T_asString( m_Shape ) ); break; } @@ -318,8 +322,7 @@ const wxPoint DRAWSEGMENT::GetCenter() const break; default: - wxASSERT_MSG( false, "DRAWSEGMENT::GetCentre not implemented for shape" - + ShowShape( GetShape() ) ); + wxFAIL_MSG( "DRAWSEGMENT::GetCentre not implemented for " + STROKE_T_asString( m_Shape ) ); break; } @@ -564,6 +567,8 @@ const EDA_RECT DRAWSEGMENT::GetBoundingBox() const break; default: + wxFAIL_MSG( "DRAWSEGMENT::GetBoundingBox not implemented for " + + STROKE_T_asString( m_Shape ) ); break; } @@ -699,7 +704,8 @@ bool DRAWSEGMENT::HitTest( const wxPoint& aPosition, int aAccuracy ) const break; default: - wxASSERT_MSG( 0, wxString::Format( "unknown DRAWSEGMENT shape: %d", m_Shape ) ); + wxFAIL_MSG( "DRAWSEGMENT::HitTest (point) not implemented for " + + STROKE_T_asString( m_Shape ) ); break; } @@ -856,7 +862,8 @@ bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy default: - wxASSERT_MSG( 0, wxString::Format( "unknown DRAWSEGMENT shape: %d", m_Shape ) ); + wxFAIL_MSG( "DRAWSEGMENT::HitTest (rect) not implemented for " + + STROKE_T_asString( m_Shape ) ); break; } diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index fe3db632eb..9ee1b9c428 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -314,7 +314,8 @@ void D_PAD::BuildEffectiveShapes() const break; default: - wxFAIL_MSG( "D_PAD::buildEffectiveShapes: Unsupported pad shape" ); + wxFAIL_MSG( "D_PAD::buildEffectiveShapes: Unsupported pad shape: " + + PAD_SHAPE_T_asString( effectiveShape ) ); break; } diff --git a/pcbnew/drc/drc.cpp b/pcbnew/drc/drc.cpp index d795abf81f..31ee50073b 100644 --- a/pcbnew/drc/drc.cpp +++ b/pcbnew/drc/drc.cpp @@ -991,7 +991,8 @@ void DRC::testCopperDrawItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem ) break; default: - wxFAIL_MSG( "unknown shape type" ); + wxFAIL_MSG( "DRC::testCopperDrawItem unsupported DRAWSEGMENT shape: " + + STROKE_T_asString( drawItem->GetShape() ) ); break; } } diff --git a/pcbnew/graphics_cleaner.cpp b/pcbnew/graphics_cleaner.cpp index c7f8d38a72..7d1c799f57 100644 --- a/pcbnew/graphics_cleaner.cpp +++ b/pcbnew/graphics_cleaner.cpp @@ -88,7 +88,8 @@ bool GRAPHICS_CLEANER::isNullSegment( DRAWSEGMENT* aSegment ) return aSegment->GetBezierPoints().empty(); default: - wxFAIL_MSG( wxString::Format( "unknown DRAWSEGMENT shape: %d", aSegment->GetShape() ) ); + wxFAIL_MSG( "GRAPHICS_CLEANER::isNullSegment unsupported DRAWSEGMENT shape: " + + STROKE_T_asString( aSegment->GetShape() ) ); return false; } } @@ -126,7 +127,8 @@ bool GRAPHICS_CLEANER::areEquivalent( DRAWSEGMENT* aSegment1, DRAWSEGMENT* aSegm && aSegment1->GetBezierPoints() == aSegment2->GetBezierPoints(); default: - wxFAIL_MSG( wxString::Format( "unknown DRAWSEGMENT shape: %d", aSegment1->GetShape() ) ); + wxFAIL_MSG( "GRAPHICS_CLEANER::areEquivalent unsupported DRAWSEGMENT shape: " + + STROKE_T_asString( aSegment1->GetShape() ) ); return false; } } diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index bc374edb8d..b726e8164c 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -938,7 +938,8 @@ void PCB_IO::format( DRAWSEGMENT* aSegment, int aNestLevel ) const break; default: - wxFAIL_MSG( wxT( "Cannot format invalid DRAWSEGMENT type." ) ); + wxFAIL_MSG( "PCB_IO::format cannot format unknown DRAWSEGMENT shape:" + + STROKE_T_asString( aSegment->GetShape() ) ); return; }; @@ -1025,7 +1026,8 @@ void PCB_IO::format( EDGE_MODULE* aModuleDrawing, int aNestLevel ) const break; default: - wxFAIL_MSG( wxT( "Cannot format invalid DRAWSEGMENT type." ) ); + wxFAIL_MSG( "PCB_IO::format cannot format unknown EDGE_MODULE shape:" + + STROKE_T_asString( aModuleDrawing->GetShape() ) ); return; };