KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_eda_shape.cpp File Reference

Go to the source code of this file.

Classes

class  EDA_SHAPE_MOCK
 
struct  SET_ANGLE_END_CASE
 
struct  SET_ARC_GEOMETRY_CASE
 
class  STROKE_TEST_RENDER_SETTINGS
 

Functions

static void checkVectorClose (const VECTOR2D &aActual, const VECTOR2D &aExpected, double aTolerance=1e-6)
 
static void checkVectorEqual (const VECTOR2I &aActual, const VECTOR2I &aExpected)
 
static void checkAngleClose (const EDA_ANGLE &aActual, double aExpectedDegrees, double aTolerance=1e-6)
 
static void checkAngleInRange (const EDA_ANGLE &aActual, double aMinDegrees, double aMaxDegrees)
 
static void deleteShapes (std::vector< SHAPE * > &aShapes)
 
 BOOST_AUTO_TEST_CASE (SetAngleAndEnd)
 
 BOOST_AUTO_TEST_CASE (SetArcGeometry)
 
 BOOST_AUTO_TEST_CASE (SetArcGeometryKeepsMidWhenEndsSwap)
 SetArcGeometry must keep the supplied midpoint for arcs it stores with swapped ends, as it does for unswapped ones, so an unedited arc saves back unchanged (issue 10442)
 
 BOOST_AUTO_TEST_CASE (ArcEditKeepsSmallSchematicRadius)
 Editing a small eeschema arc must not snap its radius up to the PCB-scale 1 mil minimum.
 
 BOOST_AUTO_TEST_CASE (PolygonBehaviorSurvivesAssignment)
 Verify that EDA_POLYGON_POINT_EDIT_BEHAVIOR survives EDA_SHAPE assignment.
 
 BOOST_AUTO_TEST_CASE (PolygonBehaviorSignalsRebuildWhenShapeMorphs)
 
 BOOST_AUTO_TEST_CASE (GetPolyPointsPreservesOrderAcrossOutlines)
 
 BOOST_AUTO_TEST_CASE (EllipseBasicAccessors)
 
 BOOST_AUTO_TEST_CASE (EllipseArcIsOpenCurve)
 
 BOOST_AUTO_TEST_CASE (EllipsePerimeterForCircleCase)
 
 BOOST_AUTO_TEST_CASE (EllipseMakeEffectiveShapesNonEmpty)
 
 BOOST_AUTO_TEST_CASE (ShortenSegmentForEndingsTrimsStartAndEnd)
 
 BOOST_AUTO_TEST_CASE (SegmentOpenArrowLeavesBody)
 
 BOOST_AUTO_TEST_CASE (SegmentShorteningRejectsOverrun)
 
 BOOST_AUTO_TEST_CASE (SegmentEndingTangentsPointOutward)
 
 BOOST_AUTO_TEST_CASE (OpenArrowBezierTangentsUseDepth)
 
 BOOST_AUTO_TEST_CASE (LineEndingEndpointsUseShapeOwnedSources)
 
 BOOST_AUTO_TEST_CASE (LineEndingEndpointsRejectInvalidPolys)
 
 BOOST_AUTO_TEST_CASE (EffectiveShapesIncludeClosedEnding)
 
 BOOST_AUTO_TEST_CASE (EffectiveShapesIncludeOpenArrowLegs)
 
 BOOST_AUTO_TEST_CASE (BBoxIncludesCenteredEnding)
 
 BOOST_AUTO_TEST_CASE (BBoxUsesRotatedEndingGeometry)
 
 BOOST_AUTO_TEST_CASE (PolygonConversionAppendsEndings)
 
 BOOST_AUTO_TEST_CASE (EffectiveShapesShortenArrowBody)
 
 BOOST_AUTO_TEST_CASE (StrokingShapesShortenArrowBodyOnly)
 
 BOOST_AUTO_TEST_CASE (StrokingShapesRejectConsumedSegmentBody)
 
 BOOST_AUTO_TEST_CASE (EffectiveShapesHitEndpointSquare)
 
 BOOST_AUTO_TEST_CASE (PolygonConversionShortensArrowBody)
 
 BOOST_AUTO_TEST_CASE (ShortenArcForEndingsKeepsPositiveSweep)
 
 BOOST_AUTO_TEST_CASE (ShortenArcForEndingsKeepsNegativeSweep)
 
 BOOST_AUTO_TEST_CASE (ArcShorteningRejectsOverrun)
 
 BOOST_AUTO_TEST_CASE (BezierNoEndingsReturnsSource)
 
 BOOST_AUTO_TEST_CASE (BezierCurveTrimsBothEnds)
 
 BOOST_AUTO_TEST_CASE (BezierCurveRejectsOverrun)
 
 BOOST_AUTO_TEST_CASE (ShortenedBezierPolylineUsesShortenedCurve)
 
 BOOST_AUTO_TEST_CASE (BezierPolylineRejectsOverrun)
 
 BOOST_AUTO_TEST_CASE (StrokingShortenedBezierDashes)
 
 BOOST_AUTO_TEST_CASE (PolyShorteningTrimsEnds)
 
 BOOST_AUTO_TEST_CASE (ShortenPolyForEndingsLeavesOpenArrowBody)
 
 BOOST_AUTO_TEST_CASE (PolyShorteningRejectsOverrun)
 
 BOOST_AUTO_TEST_CASE (BodyPolyPointsShortenFirstOpenOutline)
 

Variables

static const std::vector< SET_ANGLE_END_CASE > set_angle_end_cases
 
static const std::vector< SET_ARC_GEOMETRY_CASE > set_arc_geometry_cases
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/41]

BOOST_AUTO_TEST_CASE ( ArcEditKeepsSmallSchematicRadius )

Editing a small eeschema arc must not snap its radius up to the PCB-scale 1 mil minimum.

The edit helpers used to hard-code pcbIUScale, which in schematic IUs (1 IU = 100 nm) is a 25400 IU == 100 mil floor. See https://gitlab.com/kicad/code/kicad/-/issues/24396.

Definition at line 251 of file test_eda_shape.cpp.

References ARC, arc2(), center, KI_ARC_EDIT::EditArcEndpointKeepCenter(), KI_ARC_EDIT::EditArcMidKeepCenter(), end, EDA_SHAPE::GetRadius(), KiROUND(), radius, schIUScale, and EDA_SHAPE::SetArcGeometry().

◆ BOOST_AUTO_TEST_CASE() [2/41]

◆ BOOST_AUTO_TEST_CASE() [3/41]

◆ BOOST_AUTO_TEST_CASE() [4/41]

◆ BOOST_AUTO_TEST_CASE() [5/41]

◆ BOOST_AUTO_TEST_CASE() [6/41]

◆ BOOST_AUTO_TEST_CASE() [7/41]

◆ BOOST_AUTO_TEST_CASE() [8/41]

◆ BOOST_AUTO_TEST_CASE() [9/41]

◆ BOOST_AUTO_TEST_CASE() [10/41]

◆ BOOST_AUTO_TEST_CASE() [11/41]

◆ BOOST_AUTO_TEST_CASE() [12/41]

◆ BOOST_AUTO_TEST_CASE() [13/41]

◆ BOOST_AUTO_TEST_CASE() [14/41]

◆ BOOST_AUTO_TEST_CASE() [15/41]

◆ BOOST_AUTO_TEST_CASE() [16/41]

◆ BOOST_AUTO_TEST_CASE() [17/41]

◆ BOOST_AUTO_TEST_CASE() [18/41]

BOOST_AUTO_TEST_CASE ( GetPolyPointsPreservesOrderAcrossOutlines )

◆ BOOST_AUTO_TEST_CASE() [19/41]

BOOST_AUTO_TEST_CASE ( LineEndingEndpointsRejectInvalidPolys )

◆ BOOST_AUTO_TEST_CASE() [20/41]

◆ BOOST_AUTO_TEST_CASE() [21/41]

◆ BOOST_AUTO_TEST_CASE() [22/41]

◆ BOOST_AUTO_TEST_CASE() [23/41]

BOOST_AUTO_TEST_CASE ( PolygonBehaviorSurvivesAssignment )

◆ BOOST_AUTO_TEST_CASE() [24/41]

◆ BOOST_AUTO_TEST_CASE() [25/41]

◆ BOOST_AUTO_TEST_CASE() [26/41]

◆ BOOST_AUTO_TEST_CASE() [27/41]

◆ BOOST_AUTO_TEST_CASE() [28/41]

BOOST_AUTO_TEST_CASE ( SegmentEndingTangentsPointOutward )

◆ BOOST_AUTO_TEST_CASE() [29/41]

BOOST_AUTO_TEST_CASE ( SegmentOpenArrowLeavesBody )

◆ BOOST_AUTO_TEST_CASE() [30/41]

BOOST_AUTO_TEST_CASE ( SegmentShorteningRejectsOverrun )

◆ BOOST_AUTO_TEST_CASE() [31/41]

◆ BOOST_AUTO_TEST_CASE() [32/41]

◆ BOOST_AUTO_TEST_CASE() [33/41]

BOOST_AUTO_TEST_CASE ( SetArcGeometryKeepsMidWhenEndsSwap )

SetArcGeometry must keep the supplied midpoint for arcs it stores with swapped ends, as it does for unswapped ones, so an unedited arc saves back unchanged (issue 10442)

Definition at line 223 of file test_eda_shape.cpp.

References ARC, BOOST_CHECK_EQUAL(), EDA_SHAPE::EndsSwapped(), EDA_SHAPE::GetArcMid(), EDA_SHAPE::SetArcGeometry(), and swap.

◆ BOOST_AUTO_TEST_CASE() [34/41]

◆ BOOST_AUTO_TEST_CASE() [35/41]

◆ BOOST_AUTO_TEST_CASE() [36/41]

◆ BOOST_AUTO_TEST_CASE() [37/41]

BOOST_AUTO_TEST_CASE ( ShortenPolyForEndingsLeavesOpenArrowBody )

◆ BOOST_AUTO_TEST_CASE() [38/41]

BOOST_AUTO_TEST_CASE ( ShortenSegmentForEndingsTrimsStartAndEnd )

◆ BOOST_AUTO_TEST_CASE() [39/41]

◆ BOOST_AUTO_TEST_CASE() [40/41]

◆ BOOST_AUTO_TEST_CASE() [41/41]

◆ checkAngleClose()

static void checkAngleClose ( const EDA_ANGLE & aActual,
double aExpectedDegrees,
double aTolerance = 1e-6 )
static

◆ checkAngleInRange()

static void checkAngleInRange ( const EDA_ANGLE & aActual,
double aMinDegrees,
double aMaxDegrees )
static

Definition at line 64 of file test_eda_shape.cpp.

References EDA_ANGLE::AsDegrees().

Referenced by BOOST_AUTO_TEST_CASE().

◆ checkVectorClose()

static void checkVectorClose ( const VECTOR2D & aActual,
const VECTOR2D & aExpected,
double aTolerance = 1e-6 )
static

◆ checkVectorEqual()

static void checkVectorEqual ( const VECTOR2I & aActual,
const VECTOR2I & aExpected )
static

◆ deleteShapes()

static void deleteShapes ( std::vector< SHAPE * > & aShapes)
static

Variable Documentation

◆ set_angle_end_cases

const std::vector<SET_ANGLE_END_CASE> set_angle_end_cases
static
Initial value:
=
{
{
"Issue 13626: clockwise semicircle",
{-428880000, 117229160 },
{-430060565, 113472820 },
180.0,
{-431241130, 109716480 },
false
},
{
"Issue 13626: anticlockwise arc",
{ -431241130, 109716480 },
{ -434923630, 112954230 },
-138.46654568595355,
{ -439827050, 112936200 },
true
}
}

Definition at line 92 of file test_eda_shape.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ set_arc_geometry_cases

const std::vector<SET_ARC_GEOMETRY_CASE> set_arc_geometry_cases
static
Initial value:
= {
{
"Issue 15694: clockwise arc",
{ 10000000, 0 },
{ 0, 10000000 },
{ -10000000, 0 },
{ 0, 0 },
10000000,
false,
{ -10000000, 0 },
180.0,
},
{
"Issue 15694: anticlockwise arc",
{ -10000000, 0 },
{ 0, 10000000 },
{ 10000000, 0 },
{ 0, 0 },
10000000,
true,
{ 10000000, 0 },
180.0,
},
}

Definition at line 149 of file test_eda_shape.cpp.

Referenced by BOOST_AUTO_TEST_CASE().