KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_connectivity_facade.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
23#include <schematic.h>
24#include <sch_screen.h>
25#include <sch_commit.h>
26#include <sch_sheet.h>
27#include <sch_symbol.h>
28#include <bus_alias.h>
29#include <sch_label.h>
30#include <sch_line.h>
31#include <sch_bus_entry.h>
32#include <sch_pin.h>
33#include <sch_netchain.h>
35#include <gal/color4d.h>
36#include <sch_rule_area.h>
40#include <algorithm>
41#include <advanced_config.h>
42#include <connection_graph.h>
43#include <tool/tool_manager.h>
44#include <scoped_set_reset.h>
45
46using namespace SCH_CONNECTIVITY;
47
48BOOST_AUTO_TEST_SUITE( ConnectivityFacade )
49
50BOOST_AUTO_TEST_CASE( NativeSheetRenameEscapesPublishedNetPrefixes )
51{
52 SETTINGS_MANAGER settings;
53 std::unique_ptr<SCHEMATIC> schematic;
54 KI_TEST::LoadSchematic( settings, "netlists/multinetclasses/multinetclasses", schematic );
55 auto* original = schematic->GetTopLevelSheet();
56 original->SetName( "Power" );
57 auto copy = std::unique_ptr<SCH_SHEET>( static_cast<SCH_SHEET*>( original->Clone() ) );
58 const_cast<KIID&>( copy->m_Uuid ) = KIID();
59 copy->SetName( "Other" );
60 schematic->AddTopLevelSheet( copy.release() );
61 const auto paths = schematic->Hierarchy();
62 BOOST_REQUIRE_EQUAL( paths.size(), 2u );
63 SCH_LABEL* label = nullptr;
64
65 for( SCH_ITEM* item : original->GetScreen()->Items().OfType( SCH_LABEL_T ) )
66 {
67 auto* candidate = static_cast<SCH_LABEL*>( item );
68
69 if( candidate->GetText() == wxString( "NET_1" ) )
70 label = candidate;
71 }
72
73 BOOST_REQUIRE( label );
74 auto& facade = schematic->Connectivity();
75
76 auto netSettings = schematic->Project().GetProjectFile().NetSettings();
77 facade.Update( *schematic );
78 facade.ApplyNetclasses( *netSettings );
79 const auto originalAssignments = netSettings->GetNetclassLabelAssignments();
80 const std::set<wxString> expectedClasses{ wxString( "CLASS2" ), wxString( "CLASS3" ) };
81 BOOST_REQUIRE( originalAssignments.at( wxString( "/Power/NET_1" ) ) == expectedClasses );
82 BOOST_REQUIRE( originalAssignments.at( wxString( "/Other/NET_1" ) ) == expectedClasses );
83 const KIGFX::COLOR4D powerColor( 1.0, 0.0, 0.0, 1.0 );
84 const KIGFX::COLOR4D otherColor( 0.0, 0.0, 1.0, 1.0 );
85 netSettings->SetNetColorAssignment( wxString( "/Power/NET_1" ), powerColor );
86 netSettings->SetNetColorAssignment( wxString( "/Other/NET_1" ), otherColor );
87 SCH_SHEET_PATH topLevel;
88 topLevel.push_back( original );
89
90 for( const auto& [name, prefix] : std::vector<std::pair<wxString, wxString>>{
91 { "Power", "/Power/" }, { "Power/Supply", "/Power{slash}Supply/" },
92 { "Power", "/Power/" } } )
93 {
94 const wxString oldPrefix = topLevel.PathHumanReadable( true, false, true );
95 original->SetName( name );
96 const wxString newPrefix = topLevel.PathHumanReadable( true, false, true );
97 BOOST_CHECK_EQUAL( newPrefix, prefix );
98 netSettings->RenameNetPathPrefix( oldPrefix, newPrefix );
99 facade.Update( *schematic );
100 facade.ApplyNetclasses( *netSettings );
101 std::map<wxString, std::set<wxString>> expectedAssignments;
102
103 for( const auto& [net, classes] : originalAssignments )
104 {
105 expectedAssignments[net.StartsWith( "/Power/" ) ? prefix + net.Mid( 7 ) : net] = classes;
106 }
107
108 const std::map<wxString, KIGFX::COLOR4D> expectedColors{
109 { prefix + "NET_1", powerColor }, { "/Other/NET_1", otherColor }
110 };
111 BOOST_CHECK( netSettings->GetNetclassLabelAssignments() == expectedAssignments );
112 BOOST_CHECK( netSettings->GetNetColorAssignments() == expectedColors );
113
114 for( const auto& path : paths )
115 {
116 const wxString expected = path.Last() == original ? prefix + "NET_1" : wxString( "/Other/NET_1" );
117 const auto view = facade.Connection( label->m_Uuid, path.Path() );
118 BOOST_REQUIRE( view );
119 BOOST_CHECK_EQUAL( view->Name(), expected );
120 }
121
122 const auto incremental = facade.Published().Rows();
123 facade.Update( *schematic, true );
124 facade.ApplyNetclasses( *netSettings );
125 BOOST_CHECK( facade.Published().Rows() == incremental );
126 BOOST_CHECK( netSettings->GetNetclassLabelAssignments() == expectedAssignments );
127 BOOST_CHECK( netSettings->GetNetColorAssignments() == expectedColors );
128 }
129}
130
131BOOST_AUTO_TEST_CASE( NativeTopLevelRootsRetainLocalAndGlobalScope )
132{
133 for( const wxString& fixture : { wxString( "issue7203" ), wxString( "issue22938/issue22938" ) } )
134 {
135 BOOST_TEST_CONTEXT( fixture )
136 {
137 SETTINGS_MANAGER settings;
138 std::unique_ptr<SCHEMATIC> schematic;
139 KI_TEST::LoadSchematic( settings, fixture, schematic );
140 SCH_SHEET* original = schematic->GetTopLevelSheet();
141 original->SetName( "First" );
142 auto copy = std::unique_ptr<SCH_SHEET>( static_cast<SCH_SHEET*>( original->Clone() ) );
143 const_cast<KIID&>( copy->m_Uuid ) = KIID();
144 copy->SetName( "Second" );
145 schematic->AddTopLevelSheet( copy.release() );
146 std::vector<SCH_SHEET_PATH> roots;
147
148 for( const SCH_SHEET_PATH& path : schematic->Hierarchy() )
149 {
150 if( path.size() == 1 )
151 roots.push_back( path );
152 }
153
154 BOOST_REQUIRE_EQUAL( roots.size(), 2 );
155 BOOST_REQUIRE( roots[0].LastScreen() == roots[1].LastScreen() );
156 SCH_SCREEN* screen = original->GetScreen();
157 SCH_ITEM* local = nullptr;
158 SCH_ITEM* global = nullptr;
159
160 for( SCH_ITEM* item : screen->Items() )
161 {
162 if( item->Type() == SCH_LABEL_T )
163 local = item;
164 else if( item->Type() == SCH_GLOBAL_LABEL_T )
165 global = item;
166 else if( item->Type() == SCH_SYMBOL_T )
167 {
168 auto* symbol = static_cast<SCH_SYMBOL*>( item );
169 const wxString value = symbol->GetField( FIELD_T::VALUE )->GetText();
170
171 if( symbol->IsLocalPower() && value == wxString( "+48V" ) )
172 local = symbol;
173 else if( symbol->IsGlobalPower() && value == wxString( "+12V" ) )
174 global = symbol;
175 }
176 }
177
178 BOOST_REQUIRE( local );
179 BOOST_REQUIRE( global );
180 const auto text = []( SCH_ITEM* item ) -> EDA_TEXT&
181 {
182 if( item->Type() == SCH_SYMBOL_T )
183 return *static_cast<SCH_SYMBOL*>( item )->GetField( FIELD_T::VALUE );
184
185 return *static_cast<SCH_LABEL_BASE*>( item );
186 };
187 const wxString localName = text( local ).GetText();
188 const wxString globalName = text( global ).GetText();
189 auto& facade = schematic->Connectivity();
190 const auto check = [&]
191 {
192 facade.Update( *schematic );
193 const auto row = [&]( SCH_ITEM* item, const SCH_SHEET_PATH& path ) -> const ITEM_RESULT&
194 {
195 if( item->Type() == SCH_SYMBOL_T )
196 {
197 const auto pins = static_cast<SCH_SYMBOL*>( item )->GetPins( &path );
198 BOOST_REQUIRE_EQUAL( pins.size(), 1 );
199 item = pins.front();
200 }
201
202 const auto instance = facade.Keys().FindInstance( path.Path() );
203 BOOST_REQUIRE( instance );
204 return facade.Published().Rows().at( { item->m_Uuid, *instance } );
205 };
206 const auto& firstLocal = row( local, roots[0] );
207 const auto& secondLocal = row( local, roots[1] );
208 const auto& firstGlobal = row( global, roots[0] );
209 const auto& secondGlobal = row( global, roots[1] );
210 BOOST_CHECK( firstLocal.component != secondLocal.component );
211 BOOST_CHECK( firstGlobal.component == secondGlobal.component );
212 BOOST_CHECK( firstLocal.component != firstGlobal.component );
213 BOOST_CHECK( secondLocal.component != secondGlobal.component );
214
215 for( const SCH_SHEET_PATH& path : roots )
216 {
217 BOOST_CHECK_EQUAL( facade.Keys().Name( row( local, path ).name ),
218 "/" + path.Last()->GetName() + "/" + text( local ).GetText() );
219 BOOST_CHECK_EQUAL( facade.Keys().Name( row( global, path ).name ), text( global ).GetText() );
220 }
221
222 const auto incremental = facade.Published().Rows();
223 facade.Update( *schematic, true );
224 BOOST_CHECK( facade.Published().Rows() == incremental );
225 };
226 check();
227 text( local ).SetText( "LOCAL_SCOPE_EDITED" );
228 screen->Update( local, false );
229 check();
230 text( global ).SetText( "GLOBAL_SCOPE_EDITED" );
231 screen->Update( global, false );
232 check();
233 text( local ).SetText( localName );
234 text( global ).SetText( globalName );
235 screen->Update( local, false );
236 screen->Update( global, false );
237 check();
238 }
239 }
240}
241
242BOOST_AUTO_TEST_CASE( AutomaticUpdateRefreshesUntrackedProjectVariables )
243{
244 SETTINGS_MANAGER settings;
245 std::unique_ptr<SCHEMATIC> schematic;
246 KI_TEST::LoadSchematic( settings, "issue7203", schematic );
247 const auto paths = schematic->Hierarchy();
248 SCH_SCREEN& screen = *paths.front().LastScreen();
249 auto labels = screen.Items().OfType( SCH_LABEL_T );
250 BOOST_REQUIRE( labels.begin() != labels.end() );
251 auto* label = static_cast<SCH_LABEL_BASE*>( *labels.begin() );
252 label->SetText( "${CACHE_NAME}" );
253 label->SetConnectivityDirty();
254 schematic->Project().GetTextVars()["CACHE_NAME"] = "FIRST";
255 auto& facade = schematic->Connectivity();
256 facade.Update( paths, 1, {} );
257 auto view = facade.Connection( label->m_Uuid, paths.front().Path() );
258 BOOST_REQUIRE( view );
259 BOOST_CHECK_EQUAL( view->Name( true ), wxString( "FIRST" ) );
260 schematic->Project().GetTextVars()["CACHE_NAME"] = "SECOND";
261 facade.Update( *schematic );
262 BOOST_CHECK_EQUAL( view->Name( true ), wxString( "SECOND" ) );
263}
264
265BOOST_AUTO_TEST_CASE( FailedUpdateClearsRetainedViews )
266{
267 SETTINGS_MANAGER settings;
268 std::unique_ptr<SCHEMATIC> schematic;
269 KI_TEST::LoadSchematic( settings, "issue7203", schematic );
270 auto& facade = schematic->Connectivity();
271 auto paths = schematic->Hierarchy();
272 facade.Update( paths, 1, {} );
273 BOOST_REQUIRE( !facade.Published().Rows().empty() );
274 const auto key = facade.Published().Rows().begin()->first;
275 const auto path = facade.Keys().Instance( key.inst );
276 auto view = facade.Connection( key.item, path );
277 BOOST_REQUIRE( view );
278 paths.push_back( paths.front() );
279 BOOST_CHECK_THROW( facade.Update( paths, 1, {} ), std::invalid_argument );
280 BOOST_CHECK( facade.Published().Rows().empty() );
281 BOOST_CHECK( !facade.Connection( key.item, path ) );
282 BOOST_CHECK( view->Name().empty() );
283 facade.Update( schematic->Hierarchy(), 1, {} );
284 BOOST_CHECK( facade.Connection( key.item, path ) );
285}
286
287BOOST_AUTO_TEST_CASE( SharedScreensAndCrossInstanceDrivers )
288{
289 SETTINGS_MANAGER settings;
290 std::unique_ptr<SCHEMATIC> schematic;
291 KI_TEST::LoadSchematic( settings, "netlists/hierarchy_aliases/hierarchy_aliases", schematic );
292 auto& facade = schematic->Connectivity();
293 const auto paths = schematic->Hierarchy();
294 BUS_ALIASES aliases;
295
296 for( const auto& alias : schematic->GetAllBusAliases() )
297 aliases.insert_or_assign( alias->GetName(), alias->Members() );
298
299 facade.Update( paths, 1, aliases );
300 std::map<SCH_SCREEN*, size_t> instances;
301
302 for( const auto& path : paths )
303 ++instances[path.LastScreen()];
304
305 const auto shared = std::find_if( instances.begin(), instances.end(),
306 []( const auto& entry ) { return entry.second > 1; } );
307 BOOST_REQUIRE( shared != instances.end() );
308 SCH_SCREEN* dirty = shared->first;
309 size_t cleanViews = 0;
310 size_t dirtyViews = 0;
312
313 for( const auto& [key, row] : facade.Published().Rows() )
314 {
315 const auto& instance = facade.Keys().Instance( key.inst );
316 const auto path = paths.GetSheetPathByKIIDPath( instance );
318 auto view = facade.Connection( key.item, instance );
319
320 if( path->LastScreen() == dirty )
321 {
322 BOOST_CHECK( !view );
323 ++dirtyViews;
324 }
325 else
326 {
327 BOOST_REQUIRE( view );
328 const auto expected = row.name == INVALID_ID ? wxString() : facade.Keys().Name( row.name );
329 BOOST_CHECK_EQUAL( view->Name(), expected );
330 ++cleanViews;
331 }
332 }
333
334 BOOST_CHECK_GT( dirtyViews, 0u );
335 BOOST_CHECK_GT( cleanViews, 0u );
336 facade.Update( paths, 1, aliases );
337
338 for( const auto& [key, row] : facade.Published().Rows() )
339 BOOST_CHECK( facade.Connection( key.item, facade.Keys().Instance( key.inst ) ) );
340}
341
342BOOST_AUTO_TEST_CASE( RecalculationSkipsScreenlessSheets )
343{
344 SETTINGS_MANAGER settings;
345 std::unique_ptr<SCHEMATIC> schematic;
346 KI_TEST::LoadSchematic( settings, "net_chains_four_nets_labeled", schematic );
347 auto sheet = std::unique_ptr<SCH_SHEET>(
348 static_cast<SCH_SHEET*>( schematic->GetTopLevelSheet()->Clone() ) );
349 const_cast<KIID&>( sheet->m_Uuid ) = KIID();
350 sheet->SetScreen( nullptr );
351 sheet->SetFileName( "net_chains_four_nets.kicad_sch" );
352 sheet->SetParent( schematic->GetTopLevelSheet() );
353 schematic->GetTopLevelSheet()->GetScreen()->Append( sheet.release() );
354 schematic->RefreshHierarchy();
355 auto& facade = schematic->Connectivity();
356 BOOST_CHECK_NO_THROW( facade.Recalculate( *schematic, true ) );
357 BOOST_CHECK( !facade.Published().Rows().empty() );
358 BOOST_CHECK( !schematic->NetChains().GetPotentialNetChains().empty() );
359}
360
361BOOST_AUTO_TEST_CASE( RecalculationRestoresNativeDirectiveAttachments )
362{
363 SETTINGS_MANAGER settings;
364 std::unique_ptr<SCHEMATIC> schematic;
365 KI_TEST::LoadSchematic( settings, "netlists/multinetclasses/multinetclasses", schematic );
366 const auto path = schematic->Hierarchy().front();
367 std::map<SCH_DIRECTIVE_LABEL*, std::unordered_set<SCH_RULE_AREA*>> expected;
368
369 for( SCH_ITEM* item : path.LastScreen()->Items().OfType( SCH_DIRECTIVE_LABEL_T ) )
370 {
371 auto* directive = static_cast<SCH_DIRECTIVE_LABEL*>( item );
372 const auto areas = directive->GetConnectedRuleAreas();
373
374 if( !areas.empty() )
375 {
376 expected.emplace( directive, areas );
377 directive->ClearConnectedRuleAreas();
378 }
379 }
380
381 BOOST_REQUIRE( !expected.empty() );
382 auto& facade = schematic->Connectivity();
383 facade.Update( *schematic );
384 facade.Recalculate( *schematic, false );
385 BOOST_REQUIRE( facade.Published().Changes().changedItems.empty() );
386
387 for( const auto& [directive, areas] : expected )
388 {
389 BOOST_CHECK( directive->GetConnectedRuleAreas() == areas );
390 BOOST_CHECK( !directive->IsDangling() );
391 }
392}
393
394BOOST_AUTO_TEST_CASE( RecalculationRestoresNativeEndpointFlags )
395{
396 SETTINGS_MANAGER settings;
397 std::unique_ptr<SCHEMATIC> schematic;
398 KI_TEST::LoadSchematic( settings, "netlists/hierarchy_aliases/hierarchy_aliases", schematic );
399 const auto paths = schematic->Hierarchy();
400 schematic->ConnectionGraph()->Recalculate( paths, true );
401 std::vector<std::tuple<SCH_LINE*, bool, bool>> lines;
402 std::vector<std::tuple<SCH_BUS_ENTRY_BASE*, bool, bool>> entries;
403 std::set<SCH_SCREEN*> seen;
404
405 for( const auto& path : paths )
406 {
407 SCH_SCREEN* screen = path.LastScreen();
408
409 if( !seen.insert( screen ).second )
410 continue;
411
412 for( SCH_ITEM* item : screen->Items() )
413 {
414 if( auto* line = dynamic_cast<SCH_LINE*>( item ); line && line->IsConnectable() )
415 {
416 lines.emplace_back( line, line->IsStartDangling(), line->IsEndDangling() );
417 line->SetDanglingState( !line->IsStartDangling(), !line->IsEndDangling() );
418 }
419 else if( auto* entry = dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ) )
420 {
421 entries.emplace_back( entry, entry->IsStartDangling(), entry->IsEndDangling() );
422 entry->SetDanglingState( !entry->IsStartDangling(), !entry->IsEndDangling() );
423 }
424 }
425 }
426
427 BOOST_REQUIRE( !lines.empty() );
428 BOOST_REQUIRE( !entries.empty() );
429 schematic->Connectivity().Recalculate( *schematic );
430
431 for( const auto& [line, start, end] : lines )
432 {
433 BOOST_CHECK_EQUAL( line->IsStartDangling(), start );
434 BOOST_CHECK_EQUAL( line->IsEndDangling(), end );
435 }
436
437 for( const auto& [entry, start, end] : entries )
438 {
439 BOOST_CHECK_EQUAL( entry->IsStartDangling(), start );
440 BOOST_CHECK_EQUAL( entry->IsEndDangling(), end );
441 }
442}
443
444BOOST_AUTO_TEST_CASE( RecalculationUsesCurrentInstanceForSharedPinFlags )
445{
446 SETTINGS_MANAGER settings;
447 std::unique_ptr<SCHEMATIC> schematic;
448 KI_TEST::LoadSchematic( settings, "legacy_hierarchy/legacy_hierarchy", schematic );
449 const auto paths = schematic->BuildSheetListSortedByPageNumbers();
450 std::map<SCH_SCREEN*, std::vector<SCH_SHEET_PATH>> instances;
451
452 for( const auto& path : paths )
453 instances[path.LastScreen()].push_back( path );
454
455 SCH_SYMBOL* symbol = nullptr;
456 std::vector<SCH_SHEET_PATH> shared;
457
458 for( const auto& [screen, candidates] : instances )
459 {
460 if( candidates.size() < 2 )
461 continue;
462
463 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
464 {
465 auto* candidate = static_cast<SCH_SYMBOL*>( item );
466
467 if( candidate->GetUnitCount() > 1 )
468 {
469 symbol = candidate;
470 shared = candidates;
471 break;
472 }
473 }
474
475 if( symbol )
476 break;
477 }
478
479 BOOST_REQUIRE( symbol );
480 symbol->SetUnitSelection( &shared.front(), 1 );
481 symbol->SetUnitSelection( &shared.back(), 2 );
482
483 for( size_t selected : { size_t( 0 ), shared.size() - 1, size_t( 0 ) } )
484 {
485 const auto& path = shared[selected];
486 const int unit = symbol->GetUnitSelection( &path );
487 schematic->SetCurrentSheet( path );
488 path.UpdateAllScreenReferences();
489 schematic->ConnectionGraph()->Recalculate( paths, true );
490 SCH_PIN* pin = nullptr;
491
492 for( SCH_PIN* candidate : symbol->GetPins( &path ) )
493 {
494 if( candidate->GetLibPin()->GetUnit() == unit
495 && candidate->GetType() != ELECTRICAL_PINTYPE::PT_NC
496 && candidate->GetType() != ELECTRICAL_PINTYPE::PT_NIC )
497 {
498 pin = candidate;
499 break;
500 }
501 }
502
504 const bool dangling = pin->IsDangling();
505 pin->SetIsDangling( !dangling );
506 BOOST_REQUIRE( pin->IsDangling() != dangling );
507 schematic->Connectivity().Recalculate( *schematic );
508 BOOST_CHECK_EQUAL( pin->IsDangling(), dangling );
509 }
510}
511
512BOOST_AUTO_TEST_CASE( NativePassthroughCommitRebuildsNetChains )
513{
514 auto& enabled = const_cast<ADVANCED_CFG&>( ADVANCED_CFG::GetCfg() ).m_ConnectivityEngine;
515 SCOPED_SET_RESET restore( enabled, false );
516 SETTINGS_MANAGER settings;
517 std::unique_ptr<SCHEMATIC> schematic;
518 KI_TEST::LoadSchematic( settings, "net_chains_four_nets_labeled", schematic );
519 enabled = true;
520 schematic->RebuildConnectivity();
521 const auto path = schematic->Hierarchy().front();
522 SCH_SYMBOL* bridge = nullptr;
523
524 for( SCH_ITEM* item : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
525 {
526 auto* symbol = static_cast<SCH_SYMBOL*>( item );
527
528 if( symbol->GetRef( &path ) == wxS( "R2" ) )
529 bridge = symbol;
530 }
531
532 BOOST_REQUIRE( bridge );
533 const auto longestChain = [&]()
534 {
535 size_t nets = 0;
536
537 for( const auto& chain : schematic->NetChains().GetPotentialNetChains() )
538 nets = std::max( nets, chain->GetNets().size() );
539
540 return nets;
541 };
542 const auto originalLength = longestChain();
543 BOOST_REQUIRE_EQUAL( originalLength, 4 );
544 TOOL_MANAGER manager;
545 manager.SetEnvironment( schematic.get(), nullptr, nullptr, nullptr, nullptr );
546 SCH_COMMIT commit( &manager );
547 commit.Modify( bridge, path.LastScreen() );
549 commit.Push( "Block net chain", SKIP_UNDO );
550 BOOST_CHECK_EQUAL( longestChain(), 2u );
551 schematic->RebuildConnectivity();
552 BOOST_CHECK_EQUAL( longestChain(), 2u );
553 SCH_COMMIT restoreCommit( &manager );
554 restoreCommit.Modify( bridge, path.LastScreen() );
556 restoreCommit.Push( "Restore net chain", SKIP_UNDO );
557 BOOST_CHECK_EQUAL( longestChain(), originalLength );
558}
559
const char * name
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:102
const KIID m_Uuid
Definition eda_item.h:597
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:94
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:118
virtual void SetText(const wxString &aText)
Definition eda_text.cpp:231
EE_TYPE OfType(KICAD_T aType) const
Definition sch_rtree.h:248
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Definition kiid.h:46
Base class for a bus or wire entry.
Commit for the schematic and symbol editors.
Definition sch_commit.h:54
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
const std::unordered_set< SCH_RULE_AREA * > GetConnectedRuleAreas() const
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:139
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:39
bool IsConnectable() const override
Definition sch_line.cpp:757
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:122
void BumpConnectivityRevision(KICAD_T aChangedType=TYPE_NOT_INIT)
Increment the connectivity revisions of this screen.
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Refresh a changed item in the tree and invalidate connectivity.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false, bool aEscapeSheetNames=false) const
Return the sheet path in a human readable form made from the sheet names.
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.
Definition sch_sheet.h:48
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void SetName(const wxString &aName)
Definition sch_sheet.h:143
SCH_SCREEN * GetScreen() const
Definition sch_sheet.h:145
Schematic symbol object.
Definition sch_symbol.h:74
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
void SetPassthroughMode(PASSTHROUGH_MODE aMode)
Definition sch_symbol.h:857
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
RAII class that sets an value at construction and resets it to the original value at destruction.
Master controller class:
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
Value keys and the key session of the schematic connectivity engine.
std::map< wxString, std::vector< wxString > > BUS_ALIASES
Bus alias table, from alias name to member texts.
Definition conn_bus.h:40
constexpr uint32_t INVALID_ID
Marks an unset handle.
Definition conn_keys.h:47
@ PT_NC
not connected (must be left open)
Definition pin_type.h:46
@ PT_NIC
not internally connected (may be connected to anything)
Definition pin_type.h:40
#define SKIP_UNDO
Definition sch_commit.h:38
Published connection of one item on one sheet instance.
@ VALUE
Field Value of part, i.e. "3.3K".
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(NativeSheetRenameEscapesPublishedNetPrefixes)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
std::string path
KIBIS_PIN * pin
VECTOR3I expected(15, 30, 45)
const SHAPE_LINE_CHAIN chain
VECTOR2I end
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")
@ SCH_SYMBOL_T
Definition typeinfo.h:168
@ SCH_DIRECTIVE_LABEL_T
Definition typeinfo.h:167
@ SCH_LABEL_T
Definition typeinfo.h:163
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:164