24#include <boost/test/unit_test.hpp>
68 added.
label = wxS(
"a" );
71 removed.
label = wxS(
"r" );
74 modified.
label = wxS(
"m" );
77 conflict.
label = wxS(
"c" );
80 BOOST_CHECK(
ShapesFor( scene, CATEGORY::ADDED ).at( 0 ).label == wxS(
"a" ) );
81 BOOST_CHECK(
ShapesFor( scene, CATEGORY::REMOVED ).at( 0 ).label == wxS(
"r" ) );
82 BOOST_CHECK(
ShapesFor( scene, CATEGORY::MODIFIED ).at( 0 ).label == wxS(
"m" ) );
83 BOOST_CHECK(
ShapesFor( scene, CATEGORY::CONFLICT ).at( 0 ).label == wxS(
"c" ) );
92 BOOST_CHECK( poly.
outline.empty() );
107 BOOST_CHECK( !poly.
filled );
108 BOOST_CHECK( poly.
color == color );
117 change.
typeName = wxS(
"FOOTPRINT" );
118 change.
refdes = wxS(
"U7" );
136 track.
typeName = wxS(
"PCB_TRACK" );
137 track.
refdes = wxS(
"GND" );
141 pad.typeName = wxS(
"PAD" );
142 pad.refdes = wxS(
"GND" );
187 scene.
addedShapes.push_back( makeShape( wxS(
"/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" ),
189 scene.
modifiedShapes.push_back( makeShape( wxS(
"/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb" ),
192 std::array<bool, CATEGORY_COUNT> allVisible{ {
true,
true,
true,
true } };
197 BOOST_CHECK( found->Contains(
VECTOR2I( 105, 105 ) ) );
204 scene.
addedShapes.push_back( makeShape( wxS(
"/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" ),
208 std::array<bool, CATEGORY_COUNT> visible{ {
false,
true,
true,
true } };
212 BOOST_CHECK( !found.has_value() );
222 const wxString
id = wxS(
"/cccccccc-cccc-cccc-cccc-cccccccccccc" );
226 std::array<bool, CATEGORY_COUNT> allVisible{ {
true,
true,
true,
true } };
231 BOOST_CHECK( found->Contains(
VECTOR2I( 5, 5 ) ) );
232 BOOST_CHECK( found->Contains(
VECTOR2I( 105, 105 ) ) );
243 c1.
id =
KIID_PATH( wxS(
"/11111111-1111-1111-1111-111111111111" ) );
247 c2.
id =
KIID_PATH( wxS(
"/22222222-2222-2222-2222-222222222222" ) );
252 c3.
id =
KIID_PATH( wxS(
"/33333333-3333-3333-3333-333333333333" ) );
257 std::map<KIID_PATH, BOX2I> out;
261 BOOST_CHECK( out.count( c1.
id ) == 1 );
262 BOOST_CHECK( out.count( c2.
id ) == 1 );
263 BOOST_CHECK( out.count( c3.
id ) == 0 );
272 parent.
id =
KIID_PATH( wxS(
"/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" ) );
276 child.
id =
KIID_PATH( wxS(
"/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb" ) );
282 std::map<KIID_PATH, BOX2I> out;
286 BOOST_CHECK( out.count( parent.
id ) == 1 );
287 BOOST_CHECK( out.count( child.
id ) == 1 );
296 c.
id =
KIID_PATH( wxS(
"/11111111-1111-1111-1111-111111111111" ) );
300 std::map<KIID_PATH, BOX2I> out;
306 BOOST_CHECK( out.at( c.
id ).GetOrigin() ==
VECTOR2I( 999, 999 ) );
391 BOOST_CHECK( out == kind );
412 BOOST_CHECK( out == kind );
628 BOOST_REQUIRE_EQUAL( filtered.
segments.size(), 1u );
629 BOOST_CHECK( filtered.
segments[0].layers.none() );
650 BOOST_REQUIRE_EQUAL( filtered.
polygons.size(), 1u );
652 BOOST_CHECK( filtered.
circles.empty() );
782 BOOST_REQUIRE_EQUAL( scene.
addedShapes.size(), 1u );
852 diff.
changes.push_back( std::move( fp ) );
857 BOOST_REQUIRE_EQUAL( scene.
addedShapes.size(), 1u );
859 auto hasId = [](
const std::vector<SCENE_SHAPE>& aShapes,
const KIID_PATH& aId )
861 return std::any_of( aShapes.begin(), aShapes.end(),
864 return aShape.changeId == aId;
870 BOOST_CHECK( hasId( scene.
addedShapes, addPadId ) );
880 track.
refdes = wxS(
"Net-(U1-Pad1)" );
884 via.refdes = wxS(
"Net-(U1-Pad1)" );
886 diff.
changes.push_back( std::move( track ) );
892 BOOST_CHECK( scene.
modifiedShapes[0].label == wxS(
"NET [Net-(U1-Pad1)]" ) );
906 diff.
changes.push_back( std::move( c ) );
915 BOOST_CHECK( scene.
modifiedShapes[0].label == wxS(
"FOOTPRINT [U7]" ) );
924 diff.
changes.push_back( std::move( c ) );
928 BOOST_REQUIRE_EQUAL( scene.
addedShapes.size(), 1u );
929 BOOST_CHECK( scene.
addedShapes[0].label == wxS(
"ZONE" ) );
955 d.
name = wxS(
"Outline" );
961 diff.
changes.push_back( std::move( c ) );
966 BOOST_REQUIRE_EQUAL( scene.
addedShapes.size(), 1u );
967 BOOST_CHECK( !scene.
addedShapes[0].polygons.empty() );
982 d.
name = wxS(
"Outline" );
988 diff.
changes.push_back( std::move( c ) );
993 BOOST_REQUIRE_EQUAL( scene.
addedShapes.size(), 1u );
994 BOOST_CHECK( !scene.
addedShapes[0].polygons.empty() );
1010 d.
name = wxS(
"Filled Area (F.Cu)" );
1016 diff.
changes.push_back( std::move( c ) );
1021 BOOST_REQUIRE_EQUAL( scene.
addedShapes.size(), 1u );
1022 BOOST_CHECK( !scene.
addedShapes[0].polygons.empty() );
constexpr const Vec GetEnd() const
constexpr size_type GetWidth() const
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr const Vec & GetOrigin() const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
A typed sum value used to carry the before/after of any single property.
std::vector< std::vector< std::vector< VECTOR2I > > > PolygonSet
static DIFF_VALUE FromPolygonSet(PolygonSet aValue)
A color representation with 4 components: red, green, blue, alpha.
static const COLOR4D WHITE
LSET is a set of PCB_LAYER_IDs.
CHANGE_KIND
Coarse classification of a single item-level change between two documents.
constexpr std::size_t CATEGORY_COUNT
wxString ChangeDisplayLabel(const ITEM_CHANGE &aChange)
User-facing item label used consistently by scene tooltips and change tree entries.
DIFF_SCENE BuildScene(const DOCUMENT_DIFF &aDiff, const DIFF_COLOR_THEME &aTheme)
Build a DIFF_SCENE from a DOCUMENT_DIFF, populating the shape lists and computing the union bbox.
DOCUMENT_POLYGON MakeBBoxOutline(const BOX2I &aBBox, const KIGFX::COLOR4D &aColor, int aLineWidth)
Build a DOCUMENT_POLYGON outlining a bounding box.
ITEM_RES
Resolution kind for a whole item.
constexpr int EffectivePlotWidth(int aWidth)
Return aWidth if positive, otherwise PLOT_HAIRLINE_IU.
const char * PropResToString(PROP_RES aRes)
Canonical lower-case spellings for PROP_RES used inside the JSON serialization of PROPERTY_RESOLUTION...
PROP_RES PropResFromString(const std::string &aStr)
constexpr int PLOT_HAIRLINE_IU
Minimum stroke width the headless plotter will use when a primitive declares a non-positive line widt...
void CollectChangeBBoxes(const DOCUMENT_DIFF &aDiff, std::map< KIID_PATH, BOX2I > &aOut)
Walk a DOCUMENT_DIFF and populate a (KIID_PATH → BOX2I) map with each changed item's bbox,...
KIGFX::COLOR4D ThemeColorFor(const DIFF_COLOR_THEME &aTheme, CATEGORY aCategory)
Map a CATEGORY to its color in a DIFF_COLOR_THEME.
std::optional< BOX2I > HighlightedBBox(const DIFF_SCENE &aScene, const KIID_PATH &aChangeId, const std::array< bool, CATEGORY_COUNT > &aCategoryVisible)
Union bbox of every visible SCENE_SHAPE whose changeId matches aChangeId.
void AppendGeometry(DOCUMENT_GEOMETRY &aDst, DOCUMENT_GEOMETRY &&aSrc)
Move all primitives from aSrc into aDst.
ITEM_RES ItemResFromString(const std::string &aStr)
PROP_RES
Resolution kind for a single property of a single item.
void ExpandBBoxToGeometry(DIFF_SCENE &aScene)
Grow the scene's documentBBox to also include the extent of any background geometry.
bool IsRoutingNetChange(const ITEM_CHANGE &aChange)
Presentation predicate for PCB routing changes that should be displayed as one net-level entry/shape.
const char * ItemResToString(ITEM_RES aRes)
Canonical snake_case spellings used in MERGE_PLAN JSON serialization (take_ours / take_theirs / take_...
const std::vector< SCENE_SHAPE > & ShapesFor(const DIFF_SCENE &aScene, CATEGORY aCategory)
Read-only access to a DIFF_SCENE's shape list for a given category.
constexpr std::array< CATEGORY, 4 > PAINT_ORDER
Paint order.
std::optional< BOX2I > BBoxFromGeometry(const DOCUMENT_GEOMETRY &aGeometry)
Compute the tight bounding box of a DOCUMENT_GEOMETRY, inflating each primitive by half its stroke so...
CATEGORY CategoryFor(CHANGE_KIND aKind)
Map a CHANGE_KIND to the visual category it belongs to.
DOCUMENT_GEOMETRY FilterGeometryByVisibleLayers(const DOCUMENT_GEOMETRY &aGeometry, const LSET &aVisibleLayers)
Copy geometry primitives whose layer set intersects aVisibleLayers.
_OUT_STRING AsString(const std::string &aString)
std::vector< SCENE_SHAPE > modifiedShapes
DOCUMENT_GEOMETRY referenceGeometry
Background geometry from the two source documents.
std::vector< SCENE_SHAPE > conflictShapes
std::vector< SCENE_SHAPE > addedShapes
DOCUMENT_GEOMETRY comparisonGeometry
std::vector< SCENE_SHAPE > removedShapes
Filled or stroked circle.
The full set of changes between two parsed documents of one type.
std::vector< ITEM_CHANGE > changes
Aggregate of background geometry extracted from one source document.
std::vector< DOCUMENT_SEGMENT > segments
std::vector< DOCUMENT_POLYGON > polygons
std::vector< DOCUMENT_CIRCLE > circles
Closed polygon outline from a source document.
std::vector< VECTOR2I > outline
Stroked line segment from one of the source documents.
One change record on a single item.
std::vector< PROPERTY_DELTA > properties
std::optional< wxString > refdes
std::vector< ITEM_CHANGE > children
Single (name, before, after) triple for one mutated property on an item.
Shared rendering model consumed by both the GAL renderer (interactive widget) and the plotter rendere...
KIID_PATH changeId
Stable identifier of the ITEM_CHANGE that produced this shape.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(CategoryForMapsAllChangeKinds)
static DIFF_VALUE RectPolygonSet(const BOX2I &aBox)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I