20#include <boost/test/unit_test.hpp>
70 BOOST_CHECK(
text.IsSelected() );
79 for(
bool useEngine : {
false,
true } )
85 std::unique_ptr<SCHEMATIC> schematic;
93 auto* candidate =
static_cast<SCH_LABEL*
>( item );
95 if( candidate->GetText() ==
"NET_2" )
100 schematic->ConnectionGraph()->Reset();
101 schematic->Connectivity().Clear();
104 manager.
SetEnvironment( schematic.get(),
nullptr,
nullptr,
nullptr,
nullptr );
106 commit.
Modify( label, screen );
107 label->
SetText(
"DEFERRED_CONNECTIVITY" );
109 BOOST_CHECK( commit.
Empty() );
111 BOOST_CHECK( schematic->ConnectionGraph()->GetNetMap().empty() );
112 schematic->RecalculateConnections(
nullptr,
GLOBAL_CLEANUP, &manager );
123 std::unique_ptr<SCHEMATIC> schematic;
125 SCH_SCREEN* screen = schematic->GetCurrentScreen();
126 auto* wire =
dynamic_cast<SCH_LINE*
>(
128 auto* other =
dynamic_cast<SCH_LINE*
>(
131 const VECTOR2I start = wire->GetStartPoint();
134 manager.
SetEnvironment( schematic.get(),
nullptr,
nullptr,
nullptr,
nullptr );
136 move.Modify( wire, screen );
137 wire->Move( other->GetStartPoint() - start );
139 schematic->CleanUp( &
move, screen );
144 BOOST_CHECK( wire->GetStartPoint() == start );
145 BOOST_CHECK( wire->GetEndPoint() ==
end );
155 for(
const auto& [backend, skipDirty] : { std::pair{
false,
false }, std::pair{
true,
false },
156 std::pair{
false,
true }, std::pair{
true,
true } } )
162 std::unique_ptr<SCHEMATIC> schematic;
164 SCH_SCREEN* screen = schematic->Hierarchy().front().LastScreen();
166 wire->SetEndPoint(
VECTOR2I( -9000000, -10000000 ) );
168 schematic->RebuildConnectivity();
170 manager.
SetEnvironment( schematic.get(),
nullptr,
nullptr,
nullptr,
nullptr );
173 commit.
Modify( wire, screen );
174 wire->Move(
VECTOR2I( 100000, 0 ) );
186 for(
bool useEngine : {
false,
true } )
192 std::unique_ptr<SCHEMATIC> schematic;
194 schematic->RebuildConnectivity();
195 SCH_SCREEN* screen = schematic->Hierarchy().front().LastScreen();
200 auto* line =
static_cast<SCH_LINE*
>( item );
202 if( line->IsWire() && !line->IsDangling() )
212 const auto dump = [&]()
217 const auto before =
dump();
219 manager.
SetEnvironment( schematic.get(),
nullptr,
nullptr,
nullptr,
nullptr );
221 unchanged.
Modify( wire, screen );
226 commit.
Modify( wire, screen );
242 auto* candidate =
static_cast<SCH_SYMBOL*
>( item );
253 std::vector<bool> dangling;
255 symbolCommit.
Modify( symbol, screen );
259 dangling.push_back(
pin->IsDangling() );
260 pin->SetIsDangling( !
pin->IsDangling() );
268 for(
size_t i = 0; i < dangling.size(); ++i )
277 deferred.
Modify( wire, screen );
284 schematic->RebuildConnectivity();
287 auto graphic = std::unique_ptr<SCH_LINE>(
static_cast<SCH_LINE*
>( wire->
Duplicate(
false ) ) );
291 screen->
Append( graphic.release() );
292 schematic->RebuildConnectivity();
294 drawingEdit.
Modify( drawing, screen );
299 drawingRemoval.
Remove( drawing, screen );
311 const auto check = [&](
const char* fixture,
const wxString& pinText,
size_t expectedParentInstances )
315 for(
bool useEngine : {
false,
true } )
319 config.m_ConnectivityEngine = useEngine;
320 config.m_IncrementalConnectivity =
true;
322 std::unique_ptr<SCHEMATIC> schematic;
325 manager.
SetEnvironment( schematic.get(),
nullptr,
nullptr,
nullptr,
nullptr );
328 size_t parentInstances = 0;
336 if( candidate->GetText() == pinText )
341 schematic->SetCurrentSheet(
path );
344 screen =
path.LastScreen();
352 BOOST_REQUIRE_EQUAL( parentInstances, expectedParentInstances );
353 schematic->RecalculateConnections(
nullptr,
GLOBAL_CLEANUP, &manager );
355 const wxString originalText =
pin->GetText();
365 const auto baseline =
dump();
367 const VECTOR2I originalPosition =
pin->GetPosition();
368 bool connectedEndpoint =
false;
372 const auto* line =
static_cast<SCH_LINE*
>( item );
374 if( ( line->IsWire() || line->IsBus() )
375 && ( line->GetStartPoint() == originalPosition
376 || line->GetEndPoint() == originalPosition ) )
378 connectedEndpoint =
true;
387 if( operation == ADD_PIN && ( !useEngine || expectedParentInstances != 1 ) )
391 std::unique_ptr<SCH_SHEET_PIN> removedPin;
394 for(
bool restoring : {
false,
true } )
399 commit.
Modify( owner, screen );
401 if( operation == RENAME )
403 pin->SetText( restoring ? originalText
404 : wxString(
"UNMATCHED_NATIVE_PORT" ) );
406 else if( operation ==
MOVE )
409 owner->
Move(
delta * ( restoring ? -1 : 1 ) );
419 auto duplicate = std::unique_ptr<SCH_SHEET_PIN>(
428 BOOST_CHECK( schematic->Hierarchy() == hierarchy );
429 const auto edited =
dump();
434 BOOST_CHECK( edited != baseline );
436 schematic->RebuildConnectivity();
446 check(
"issue9673/issue9673", wxString(
"INT" ), 1 );
447 check(
"netlists/hierarchy_aliases/hierarchy_aliases", wxString(
"{ALIAS2}" ), 2 );
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
bool IsContentModified() const
void SetContentModified(bool aModified=true)
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void SetText(const wxString &aText)
EE_TYPE OfType(KICAD_T aType) const
Commit for the schematic and symbol editors.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE) override
Add a change of the item aItem of type aChangeType to the change list.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
A set of SCH_ITEMs (i.e., without duplicates).
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool aDoClone=false) const
Routine to create a new copy of given item.
void SetConnectivityDirty(bool aDirty=true)
Set the dirty flag.
bool IsConnectivityDirty() const
std::optional< wxString > GetConnectionName(const SCH_SHEET_PATH *aSheet=nullptr, bool aLocal=false, bool aIgnoreSheet=false) const
Return the active connection name; absent for missing or stale published rows.
Segment description base class to describe items which have 2 end points (track, wire,...
bool IsStartDangling() const
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
bool IsEndDangling() const
void SetDanglingState(bool aStart, bool aEnd)
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
SCH_ITEM * GetConnectivityItem(const KIID &aId) const
Resolve a drawing item or a connectable child on this screen; ambiguous IDs return null.
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Refresh a changed item in the tree and invalidate connectivity.
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
void RemovePin(const SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
VECTOR2I GetPosition() const override
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit, int aBodyStyle) const override
RAII class that sets an value at construction and resets it to the original value at destruction.
#define SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
#define STRUCT_DELETED
flag indication structures to be erased
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
std::string Dump(SCHEMATIC &aSchematic)
Canonical, pointer-free connectivity rows for migration and rebuild comparisons.
#define SKIP_CONNECTIVITY
#define DELETE_REMOVED_ITEMS
Class to handle a set of SCH_ITEMs.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(RecursesThroughGroups)
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
VECTOR2< int32_t > VECTOR2I