20#include <boost/test/unit_test.hpp>
39 std::unique_ptr<SCH_NETCHAIN> aChain );
64 graph->
Recalculate( m_schematic->BuildSheetListSortedByPageNumbers(),
true );
67 std::map<wxString, wxString> classes;
68 std::map<wxString, KIGFX::COLOR4D> colors;
69 classes[wxT(
"MY_CHAIN" )] = wxT(
"DDR_DATA" );
90 BOOST_CHECK_CLOSE( committed->
GetColor().
r, 1.0, 1e-6 );
91 BOOST_CHECK_CLOSE( committed->
GetColor().
g, 0.5, 1e-6 );
92 BOOST_CHECK_CLOSE( committed->
GetColor().
b, 0.25, 1e-6 );
93 BOOST_CHECK_CLOSE( committed->
GetColor().
a, 1.0, 1e-6 );
110 graph->
Recalculate( m_schematic->BuildSheetListSortedByPageNumbers(),
true );
143 std::shared_ptr<NET_SETTINGS> ns = m_schematic->Project().GetProjectFile().NetSettings();
147 std::shared_ptr<NETCLASS> highSpeed = std::make_shared<NETCLASS>( wxT(
"HighSpeed" ) );
148 ns->SetNetclass( wxT(
"HighSpeed" ), highSpeed );
150 auto chain = std::make_unique<SCH_NETCHAIN>();
151 chain->SetName( wxT(
"DQ_CHAIN" ) );
152 chain->AddNet( wxT(
"/NET_A" ) );
153 chain->AddNet( wxT(
"/NET_B" ) );
154 chain->SetNetClass( wxT(
"HighSpeed" ) );
161 BOOST_CHECK_EQUAL( ns->GetEffectiveNetClass( wxT(
"/NET_A" ) )->GetName(), wxString( wxT(
"HighSpeed" ) ) );
162 BOOST_CHECK_EQUAL( ns->GetEffectiveNetClass( wxT(
"/NET_B" ) )->GetName(), wxString( wxT(
"HighSpeed" ) ) );
176 std::shared_ptr<NET_SETTINGS> ns = m_schematic->Project().GetProjectFile().NetSettings();
179 std::shared_ptr<NETCLASS> highSpeed = std::make_shared<NETCLASS>( wxT(
"HighSpeed" ) );
180 ns->SetNetclass( wxT(
"HighSpeed" ), highSpeed );
184 auto chain = std::make_unique<SCH_NETCHAIN>();
185 chain->SetName( wxT(
"DQ_CHAIN" ) );
186 chain->AddNet( wxT(
"/NET_A" ) );
187 chain->AddNet( synthetic );
188 chain->SetNetClass( wxT(
"HighSpeed" ) );
193 BOOST_CHECK_EQUAL( ns->GetEffectiveNetClass( wxT(
"/NET_A" ) )->GetName(), wxString( wxT(
"HighSpeed" ) ) );
208 std::shared_ptr<NET_SETTINGS> ns = m_schematic->Project().GetProjectFile().NetSettings();
211 auto chain = std::make_unique<SCH_NETCHAIN>();
212 chain->SetName( wxT(
"DQ_CHAIN" ) );
213 chain->AddNet( wxT(
"/NET_A" ) );
214 chain->SetNetClass( wxT(
"Ghost" ) );
234 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
237 std::shared_ptr<NET_SETTINGS> ns = m_schematic->Project().GetProjectFile().NetSettings();
240 std::shared_ptr<NETCLASS> highSpeed = std::make_shared<NETCLASS>( wxT(
"HighSpeed" ) );
241 ns->SetNetclass( wxT(
"HighSpeed" ), highSpeed );
243 std::map<wxString, wxString> overrides;
244 overrides[wxT(
"MY_CHAIN" )] = wxT(
"HighSpeed" );
253 BOOST_REQUIRE_EQUAL( committed->
GetNetClass(), wxString( wxT(
"HighSpeed" ) ) );
256 std::vector<wxString> namedNets;
258 for(
const wxString& net : committed->
GetNets() )
261 namedNets.push_back( net );
270 for(
const wxString& net : namedNets )
271 BOOST_CHECK_EQUAL( ns->GetEffectiveNetClass( net )->GetName(), wxString( wxT(
"HighSpeed" ) ) );
287 std::shared_ptr<NET_SETTINGS> ns = m_schematic->Project().GetProjectFile().NetSettings();
290 std::shared_ptr<NETCLASS> highSpeed = std::make_shared<NETCLASS>( wxT(
"HighSpeed" ) );
291 ns->SetNetclass( wxT(
"HighSpeed" ), highSpeed );
293 auto chain = std::make_unique<SCH_NETCHAIN>();
294 chain->SetName( wxT(
"DQ_CHAIN" ) );
295 chain->AddNet( wxT(
"/NET_A" ) );
296 chain->SetNetClass( wxT(
"HighSpeed" ) );
301 wxString( wxT(
"HighSpeed" ) ) );
304 ns->ClearNetclasses();
Calculate the connectivity of a schematic and generates netlists.
void SetNetChainColorOverrides(const std::map< wxString, COLOR4D > &aOverrides)
void SetNetChainNetClassOverrides(const std::map< wxString, wxString > &aOverrides)
Stash per-net-chain netclass overrides read from the schematic file.
SCH_NETCHAIN * CreateNetChainFromPotential(SCH_NETCHAIN *aPotential, const wxString &aName)
Promote a potential net chain to an actual user net chain with the provided name.
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Update the connection graph for the given list of sheets.
const std::vector< std::unique_ptr< SCH_NETCHAIN > > & GetPotentialNetChains() const
Potential net chains are inferred groupings produced by RebuildNetChains() but not yet user-committed...
void ApplyNetChainNetclasses()
Mirror each committed net chain's netclass override into the project NET_SETTINGS as a chain-derived ...
A color representation with 4 components: red, green, blue, alpha.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
static const char Default[]
the name of the default NETCLASS
A net chain is a collection of nets that are connected together through passive components.
const std::set< wxString > & GetNets() const
const wxString & GetNetClass() const
const KIGFX::COLOR4D & GetColor() const
const wxString & GetName() const
static constexpr char SYNTHETIC_NET_PREFIX[]
Prefix used when synthesising net names for unnamed subgraphs.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
std::vector< FAB_LAYER_COLOR > dummy
std::unique_ptr< SCHEMATIC > m_schematic
SETTINGS_MANAGER m_settingsManager
SIGNALS_CLASS_COLOR_FIXTURE()
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
void boost_test_inject_committed_net_chain(CONNECTION_GRAPH &aGraph, std::unique_ptr< SCH_NETCHAIN > aChain)
BOOST_FIXTURE_TEST_CASE(NetChain_ApplyClassAndColorOverrides, SIGNALS_CLASS_COLOR_FIXTURE)
const SHAPE_LINE_CHAIN chain
BOOST_CHECK_EQUAL(result, "25.4")