18#define BOOST_TEST_NO_MAIN
19#include <boost/test/unit_test.hpp>
41 wxString
GetClass()
const override {
return "MockEDAItem"; }
60 helper.SetGridSnapping(
true );
81 BOOST_CHECK( helper.
GetSnap() );
97 rectangle->
SetStart( { -1000, -500 } );
98 rectangle->
SetEnd( { 1000, 500 } );
103 text->SetText( wxString(
"far away" ) );
104 text->SetTextPos( { 100000, 100000 } );
115 BOX2I bounds( { 0, 0 }, { 100, 60 } );
232 BOOST_CHECK(
result.x >= 0 );
233 BOOST_CHECK(
result.y >= 0 );
368 BOOST_CHECK( snapped ==
nullptr );
383 BOOST_CHECK( helper.
GetSnapped() ==
nullptr );
442 helper.SetGridSize(
VECTOR2D( 1000, 1000 ) );
489 auto onGrid = [](
const VECTOR2I& aPt,
int aGrid )
491 return aPt.
x % aGrid == 0 && aPt.
y % aGrid == 0;
499 "Arc drag source must not offer an ORIGIN anchor at (" << spec.pos.x
500 <<
", " << spec.pos.y <<
")" );
503 BOOST_CHECK_MESSAGE( onGrid( spec.pos,
grid ),
"ORIGIN anchor off grid" );
507 bool midOffered =
false;
515 BOOST_CHECK( midOffered );
520 bool centerAsOrigin =
false;
526 centerAsOrigin =
true;
532 BOOST_CHECK( centerAsOrigin );
constexpr EDA_IU_SCALE pcbIUScale
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Information pertinent to a Pcbnew printed circuit board.
KICAD_T Type() const
Returns the type of object.
virtual void SetVisible(bool aVisible)
void SetOrigin(const VECTOR2I &aOrigin)
void SetGridSnapping(bool aEnable)
static SNAP_REFERENCE_PREFERENCE classifyReference(const VECTOR2I &aPoint, const BOX2I &aBounds, bool aAnchorPoint)
Classify the point a drag was started from against the moving object's bounds.
void SetGridSize(const VECTOR2D &aGrid)
wxString GetClass() const override
Return the class name.
MOCK_BOARD_ITEM(KICAD_T aType)
VECTOR2I GetPosition() const override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
BOARD_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
double Similarity(const BOARD_ITEM &aItem) const override
Return a measure of how likely the other object is to represent the same object.
void SetPosition(const VECTOR2I &aPos) override
bool operator==(const BOARD_ITEM &aItem) const override
static SNAP_REFERENCE_PREFERENCE ClassifyReference(const VECTOR2I &aPoint, const BOX2I &aBounds, bool aPadCenter)
PCBGridHelperTestFixture()
static BOX2I LayoutBounds(const BOARD_ITEM &aItem)
void SetMid(const VECTOR2I &aMid)
virtual VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aRemovedItem) override
static std::vector< ANCHOR_SPEC > GetArcAnchors(const PCB_ARC &aArc, bool aFrom)
Return the snap/drag anchor points that a track arc contributes.
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
BOARD_ITEM * GetSnapped() const
Function GetSnapped If the PCB_GRID_HELPER has highlighted a snap point (target shown),...
static BOX2I layoutBounds(const BOARD_ITEM &aItem)
GRID_HELPER_GRIDS GetItemGrid(const EDA_ITEM *aItem) const override
Get the coarsest grid that applies to an item.
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
virtual VECTOR2I Align(const VECTOR2I &aPoint, GRID_HELPER_GRIDS aGrid) const
void SetEnd(const VECTOR2I &aEnd) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetStart(const VECTOR2I &aStart) override
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
static constexpr EDA_ANGLE ANGLE_90
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
A single anchor point contributed by an item, before it is registered with the helper.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
BOOST_FIXTURE_TEST_CASE(LargeGridSegmentSnap, PCBGridHelperTestFixture)
BOOST_AUTO_TEST_CASE(DefaultConstructor)
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D