Add SH_RECT handling to 3D shape conversion.
Also add some debugging for not-implemented shape cases in other places to catch simmilar issues in future. Fixes https://gitlab.com/kicad/code/kicad/issues/4757
This commit is contained in:
parent
3bb44f3804
commit
40a72d9530
|
@ -47,6 +47,7 @@
|
||||||
#include <geometry/shape_segment.h>
|
#include <geometry/shape_segment.h>
|
||||||
#include <geometry/geometry_utils.h>
|
#include <geometry/geometry_utils.h>
|
||||||
#include <geometry/shape_circle.h>
|
#include <geometry/shape_circle.h>
|
||||||
|
#include <geometry/shape_rect.h>
|
||||||
#include <geometry/shape_simple.h>
|
#include <geometry/shape_simple.h>
|
||||||
#include <gr_text.h>
|
#include <gr_text.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -368,6 +369,18 @@ void BOARD_ADAPTER::createNewPadWithClearance( const D_PAD* aPad,
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case SH_SIMPLE:
|
||||||
poly.AddOutline( static_cast<SHAPE_SIMPLE*>( shape.get() )->Vertices() );
|
poly.AddOutline( static_cast<SHAPE_SIMPLE*>( shape.get() )->Vertices() );
|
||||||
break;
|
break;
|
||||||
|
@ -377,7 +390,8 @@ void BOARD_ADAPTER::createNewPadWithClearance( const D_PAD* aPad,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( "BOARD_ADAPTER::createNewPadWithClearance unimplemented shape" );
|
wxFAIL_MSG( "BOARD_ADAPTER::createNewPadWithClearance no implementation for "
|
||||||
|
+ SHAPE_TYPE_asString( shape->Type() ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -695,6 +709,8 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const DRAWSEGMENT* aDrawSe
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
wxFAIL_MSG( "BOARD_ADAPTER::AddShapeWithClearanceToContainer no implementation for "
|
||||||
|
+ STROKE_T_asString( aDrawSegment->GetShape() ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,21 @@ enum STROKE_T
|
||||||
S_LAST ///< last value for this list
|
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
|
* BOARD_ITEM
|
||||||
|
|
|
@ -40,6 +40,21 @@ enum PAD_SHAPE_T
|
||||||
// (thick segments, circles, arcs, polygons
|
// (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
|
* Enum PAD_DRILL_SHAPE_T
|
||||||
* is the set of pad drill shapes, used with D_PAD::{Set,Get}DrillShape()
|
* is the set of pad drill shapes, used with D_PAD::{Set,Get}DrillShape()
|
||||||
|
|
|
@ -25,12 +25,8 @@
|
||||||
#ifndef __SHAPE_H
|
#ifndef __SHAPE_H
|
||||||
#define __SHAPE_H
|
#define __SHAPE_H
|
||||||
|
|
||||||
#include <assert.h> // for assert
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stddef.h> // for NULL
|
|
||||||
|
|
||||||
#include <geometry/seg.h>
|
#include <geometry/seg.h>
|
||||||
|
|
||||||
#include <math/vector2d.h>
|
#include <math/vector2d.h>
|
||||||
#include <math/box2.h>
|
#include <math/box2.h>
|
||||||
|
|
||||||
|
@ -52,6 +48,22 @@ enum SHAPE_TYPE
|
||||||
SH_ARC ///> circular arc
|
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
|
* SHAPE
|
||||||
*
|
*
|
||||||
|
|
|
@ -468,6 +468,8 @@ void DRAWSEGMENT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerB
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
wxFAIL_MSG( "DRAWSEGMENT::TransformShapeWithClearanceToPolygon no implementation for "
|
||||||
|
+ STROKE_T_asString( m_Shape ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,6 +630,11 @@ void D_PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
||||||
aCornerBuffer.Append( outline );
|
aCornerBuffer.Append( outline );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG( "D_PAD::TransformShapeWithClearanceToPolygon no implementation for "
|
||||||
|
+ PAD_SHAPE_T_asString( GetShape() ) );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,9 +219,7 @@ void DRAWSEGMENT::Rotate( const wxPoint& aRotCentre, double aAngle )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// un-handled edge transform
|
wxFAIL_MSG( "DRAWSEGMENT::Rotate not implemented for " + STROKE_T_asString( m_Shape ) );
|
||||||
wxASSERT_MSG( false, wxT( "DRAWSEGMENT::Rotate not implemented for "
|
|
||||||
+ ShowShape( m_Shape ) ) );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,7 +268,13 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case S_SEGMENT:
|
||||||
|
case S_RECT:
|
||||||
|
case S_CIRCLE:
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
wxFAIL_MSG( "DRAWSEGMENT::Flip not implemented for " + STROKE_T_asString( m_Shape ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,8 +322,7 @@ const wxPoint DRAWSEGMENT::GetCenter() const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxASSERT_MSG( false, "DRAWSEGMENT::GetCentre not implemented for shape"
|
wxFAIL_MSG( "DRAWSEGMENT::GetCentre not implemented for " + STROKE_T_asString( m_Shape ) );
|
||||||
+ ShowShape( GetShape() ) );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,6 +567,8 @@ const EDA_RECT DRAWSEGMENT::GetBoundingBox() const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
wxFAIL_MSG( "DRAWSEGMENT::GetBoundingBox not implemented for "
|
||||||
|
+ STROKE_T_asString( m_Shape ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,7 +704,8 @@ bool DRAWSEGMENT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -856,7 +862,8 @@ bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
|
||||||
|
|
||||||
|
|
||||||
default:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -314,7 +314,8 @@ void D_PAD::BuildEffectiveShapes() const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( "D_PAD::buildEffectiveShapes: Unsupported pad shape" );
|
wxFAIL_MSG( "D_PAD::buildEffectiveShapes: Unsupported pad shape: "
|
||||||
|
+ PAD_SHAPE_T_asString( effectiveShape ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -991,7 +991,8 @@ void DRC::testCopperDrawItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( "unknown shape type" );
|
wxFAIL_MSG( "DRC::testCopperDrawItem unsupported DRAWSEGMENT shape: "
|
||||||
|
+ STROKE_T_asString( drawItem->GetShape() ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,8 @@ bool GRAPHICS_CLEANER::isNullSegment( DRAWSEGMENT* aSegment )
|
||||||
return aSegment->GetBezierPoints().empty();
|
return aSegment->GetBezierPoints().empty();
|
||||||
|
|
||||||
default:
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +127,8 @@ bool GRAPHICS_CLEANER::areEquivalent( DRAWSEGMENT* aSegment1, DRAWSEGMENT* aSegm
|
||||||
&& aSegment1->GetBezierPoints() == aSegment2->GetBezierPoints();
|
&& aSegment1->GetBezierPoints() == aSegment2->GetBezierPoints();
|
||||||
|
|
||||||
default:
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -938,7 +938,8 @@ void PCB_IO::format( DRAWSEGMENT* aSegment, int aNestLevel ) const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1025,7 +1026,8 @@ void PCB_IO::format( EDGE_MODULE* aModuleDrawing, int aNestLevel ) const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue