37#include <boost/test/unit_test.hpp>
52#include <wx/filename.h>
53#include <wx/stdpaths.h>
61 wxString tempDir = wxStandardPaths::Get().GetTempDir();
62 wxString projectPath = tempDir + wxFileName::GetPathSeparator()
63 + wxT(
"test_group_annotation.kicad_pro" );
67 m_schematic = std::make_unique<SCHEMATIC>(
nullptr );
76 if( wxFileExists( file ) )
102 m_schematic->CreateDefaultScreens();
104 std::vector<SCH_SHEET*> topSheets = m_schematic->GetTopLevelSheets();
107 SCH_SCREEN* screen = topSheets[0]->GetScreen();
113 screen->
Append( symbol1 );
117 screen->
Append( symbol2 );
121 group->SetName( wxT(
"DesignBlock" ) );
122 group->AddItem( symbol1 );
123 group->AddItem( symbol2 );
127 std::unordered_set<SCH_SYMBOL*> foundSymbols;
129 group->RunOnChildren(
133 foundSymbols.insert(
static_cast<SCH_SYMBOL*
>( aChild ) );
139 BOOST_CHECK( foundSymbols.count( symbol1 ) == 1 );
140 BOOST_CHECK( foundSymbols.count( symbol2 ) == 1 );
151 m_schematic->CreateDefaultScreens();
153 std::vector<SCH_SHEET*> topSheets = m_schematic->GetTopLevelSheets();
156 SCH_SCREEN* screen = topSheets[0]->GetScreen();
162 screen->
Append( symbol1 );
166 screen->
Append( symbol2 );
170 screen->
Append( symbol3 );
174 innerGroup->
SetName( wxT(
"InnerGroup" ) );
175 innerGroup->
AddItem( symbol1 );
176 screen->
Append( innerGroup );
180 outerGroup->
SetName( wxT(
"OuterGroup" ) );
181 outerGroup->
AddItem( innerGroup );
182 outerGroup->
AddItem( symbol2 );
183 screen->
Append( outerGroup );
186 std::unordered_set<SCH_SYMBOL*> foundSymbols;
192 foundSymbols.insert(
static_cast<SCH_SYMBOL*
>( aChild ) );
198 BOOST_CHECK( foundSymbols.count( symbol1 ) == 1 );
199 BOOST_CHECK( foundSymbols.count( symbol2 ) == 1 );
200 BOOST_CHECK( foundSymbols.count( symbol3 ) == 0 );
221 m_schematic->CreateDefaultScreens();
222 m_schematic->Settings().m_refDesTracker = std::make_shared<REFDES_TRACKER>(
false );
224 std::vector<SCH_SHEET*> topSheets = m_schematic->GetTopLevelSheets();
239 existingPowerSymbol->
SetRef( &sheetPath, wxT(
"#PWR01" ) );
241 screen->
Append( existingPowerSymbol );
245 normalSymbol->
SetRef( &sheetPath, wxT(
"R123" ) );
247 screen->
Append( normalSymbol );
250 powerSymbol->
SetRef( &sheetPath, wxT(
"#PWR01" ) );
252 screen->
Append( powerSymbol );
255 group->SetName( wxT(
"DesignBlock" ) );
256 group->AddItem( normalSymbol );
257 group->AddItem( powerSymbol );
265 BOOST_REQUIRE_EQUAL( selectedSymbols.size(), 2 );
280 for(
unsigned i = 0; i < allReferences.
GetCount(); ++i )
282 if( !references.
Contains( allReferences[i] ) )
283 additionalRefs.
AddItem( allReferences[i] );
289 references.
Annotate(
false, 0, 0, lockedSymbols, additionalRefs );
void AddItem(EDA_ITEM *aItem)
Add item to group.
void SetName(const wxString &aName)
KICAD_T Type() const
Returns the type of object.
Define a library symbol object.
const LIB_ID & GetLibId() const override
Container for project specific data.
A set of SCH_ITEMs (i.e., without duplicates).
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
bool Contains(const SCH_REFERENCE &aItem) const
Return true if aItem exists in this list.
void Annotate(bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, const SCH_MULTI_UNIT_REFERENCE_MAP &aLockedUnitMap, const SCH_REFERENCE_LIST &aAdditionalRefs, bool aStartAtCurrent=false)
Set the reference designators in the list that have not been annotated.
void SetRefDesTracker(std::shared_ptr< REFDES_TRACKER > aTracker)
void SplitReferences()
Attempt to split all reference designators into a name (U) and number (1).
void RemoveAnnotation()
Treat all symbols in this list as non-annotated.
void AddItem(const SCH_REFERENCE &aItem)
void UpdateAnnotation()
Update the symbol references for the schematic project (or the current sheet).
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void AppendSymbol(SCH_REFERENCE_LIST &aReferences, SCH_SYMBOL *aSymbol, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Append a SCH_REFERENCE object to aReferences based on aSymbol.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Adds SCH_REFERENCE object to aReferences for each symbol in the sheet.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
SCH_SCREEN * GetScreen() const
void SetPosition(const VECTOR2I &aPosition) override
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
void SetValueFieldText(const wxString &aValue, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
virtual void Add(EDA_ITEM *aItem)
Class to handle a set of SCH_ITEMs.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Container to map reference designators for multi-unit parts.
std::vector< wxString > m_tempFiles
~GROUP_ANNOTATION_FIXTURE()
GROUP_ANNOTATION_FIXTURE()
std::unique_ptr< SCHEMATIC > m_schematic
SETTINGS_MANAGER m_settingsManager
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(TestGroupRunOnChildrenFindsSymbols)
Test that SCH_GROUP::RunOnChildren correctly finds symbols inside a group.
std::unordered_set< SCH_SYMBOL * > getInferredSymbols(const SCH_SELECTION &aSelection)
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I