42 for(
bool backend : {
false,
true } )
48 std::unique_ptr<SCHEMATIC> schematic;
50 SCH_SCREEN* screen = schematic->Hierarchy().front().LastScreen();
51 const int grid = schematic->Settings().m_ConnectionGridSize;
52 BOOST_REQUIRE_GT(
grid, 1 );
55 return point.x %
grid == 0 && point.y %
grid == 0;
64 auto* candidate =
static_cast<SCH_LINE*
>( item );
66 if( onGrid( candidate->GetStartPoint() ) && onGrid( candidate->GetEndPoint() ) )
73 if( onGrid( candidate->GetPosition() ) && onGrid( candidate->GetEnd() ) )
85 using POSITIONS = std::multiset<std::pair<int, int>>;
86 const auto position = [](
const VECTOR2I& point ) {
return std::pair{ point.x, point.y }; };
88 const auto check = [&](
const POSITIONS& wirePositions,
const POSITIONS& entryPositions )
92 POSITIONS actualEntry;
93 std::vector<SCH_ITEM*> markers;
97 auto* marker =
static_cast<SCH_MARKER*
>( item );
98 const auto error = std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() );
103 const KIID&
id = error->GetMainItemID();
107 (
id == wire->
m_Uuid ? actualWire : actualEntry ).insert( position( marker->GetPosition() ) );
110 markers.push_back( marker );
113 BOOST_CHECK( actualWire == wirePositions );
114 BOOST_CHECK( actualEntry == entryPositions );
120 for(
bool startOffGrid : {
true,
false } )
125 screen->
Update( wire,
false );
126 screen->
Update( entry,
false );
127 schematic->RebuildConnectivity();
128 const POSITIONS wirePositions{ position( ( startOffGrid ? start :
end ) + offset ) };
129 const POSITIONS entryPositions{ position( entryStart + offset ), position( entryEnd + offset ) };
130 check( wirePositions, entryPositions );
134 screen->
Update( wire,
false );
135 screen->
Update( entry,
false );
136 schematic->RebuildConnectivity();
150 std::unique_ptr<SCHEMATIC> schematic;
152 std::vector<SCH_SHEET_PATH> paths;
156 if(
path.LastScreen()->GetFileName().EndsWith(
"ampli_ht.kicad_sch" ) )
157 paths.push_back(
path );
160 BOOST_REQUIRE_EQUAL( paths.size(), 2 );
167 if( item->IsConnectable() )
169 wire =
static_cast<SCH_LINE*
>( item );
175 const int grid = schematic->Settings().m_ConnectionGridSize;
176 BOOST_REQUIRE_GT(
grid, 1 );
178 start.
x += start.
x %
grid == 0 ? 1 : 0;
180 screen->
Update( wire,
false );
181 schematic->RebuildConnectivity();
183 const auto markers = [&]()
185 std::vector<SCH_MARKER*>
result;
189 auto* marker =
static_cast<SCH_MARKER*
>( item );
190 const auto error = std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() );
193 result.push_back( marker );
199 BOOST_REQUIRE_EQUAL( markers().size(), 1 );
201 exclusion.SetComment(
"Saved by legacy" );
202 schematic->ErcSettings().m_ErcExclusions.insert( exclusion );
208 schematic->RebuildConnectivity();
210 schematic->ResolveERCExclusionsPostUpdate();
215 BOOST_CHECK( marker->IsExcluded() );
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
EE_TYPE OfType(KICAD_T aType) const
static ERC_EXCLUSION FromMarker(const SCH_MARKER &aMarker)
Runs the electrical rules checks and adds a SCH_MARKER for each violation.
int TestOffGridEndpoints()
Test pins and wire ends for being off grid.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
VECTOR2I GetPosition() const override
void SetPosition(const VECTOR2I &aPosition) override
Class for a wire to bus entry.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Segment description base class to describe items which have 2 end points (track, wire,...
void SetStartPoint(const VECTOR2I &aPosition)
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
void SetEndPoint(const VECTOR2I &aPosition)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Refresh a changed item in the tree and invalidate connectivity.
void DeleteItem(SCH_ITEM *aItem)
Remove aItem from the linked list and deletes the object.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
RAII class that sets an value at construction and resets it to the original value at destruction.
@ ERCE_ENDPOINT_OFF_GRID
Pin or wire-end off grid.
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
BOOST_AUTO_TEST_CASE(ERCOffGridLinesAndEntriesKeepCapturedEndpoints)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_TEST_CONTEXT("Test Clearance")
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I