KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_connectivity_export.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
21#include <qa_utils/file_utils.h>
23#include <advanced_config.h>
24#include <connection_graph.h>
31#include <richio.h>
32#include <wx/dir.h>
33#include <boost/mpl/list.hpp>
34#include <type_traits>
35#include <algorithm>
36#include <reporter.h>
37#include <schematic.h>
38#include <sch_screen.h>
39#include <sch_label.h>
40#include <sch_symbol.h>
41#include <sch_rule_area.h>
42#include <sch_netchain.h>
43#include <locale_io.h>
44#include <wx/xml/xml.h>
46#include <wx/ffile.h>
47#include <scoped_set_reset.h>
48
49
51{
53 {
54 boost::unit_test::unit_test_log.set_threshold_level(boost::unit_test::log_test_units);
55 }
56};
57
59
60BOOST_AUTO_TEST_SUITE( ConnectivityExport )
61
62BOOST_AUTO_TEST_CASE( CurrentSheetExportPreservesFullInstancePaths )
63{
64 auto& enabled = const_cast<ADVANCED_CFG&>( ADVANCED_CFG::GetCfg() ).m_ConnectivityEngine;
65 SCOPED_SET_RESET restore( enabled, enabled );
66
67 class EXPORTER : public NETLIST_EXPORTER_SPICE
68 {
69 public:
71
72 SCH_SHEET_LIST SelectedSheets()
73 {
74 CONNECTIVITY_SCOPE connectivity( *this );
75 return BuildSheetList( OPTION_CUR_SHEET_AS_ROOT );
76 }
77 };
78
79 enabled = false;
80 SETTINGS_MANAGER settings;
81 std::unique_ptr<SCHEMATIC> schematic;
82 KI_TEST::LoadSchematic( settings, "netlists/hierarchy_aliases/hierarchy_aliases", schematic );
83 const SCH_SHEET_LIST hierarchy = schematic->Hierarchy();
84 const auto selected = std::find_if( hierarchy.begin(), hierarchy.end(),
85 []( const SCH_SHEET_PATH& path )
86 {
87 return path.PathHumanReadable() == "/First Subsheet/";
88 } );
89 BOOST_REQUIRE( selected != hierarchy.end() );
90 schematic->SetCurrentSheet( *selected );
91 EXPORTER exporter( schematic.get(), nullptr );
92
93 for( bool published : { false, true } )
94 {
95 BOOST_TEST_CONTEXT( "published=" << published )
96 {
97 enabled = published;
98 const SCH_SHEET_LIST sheets = exporter.SelectedSheets();
99 BOOST_REQUIRE_EQUAL( sheets.size(), 2 );
100 std::set<wxString> names;
101
102 for( const SCH_SHEET_PATH& path : sheets )
103 {
104 BOOST_CHECK( path.at( 0 ) == selected->at( 0 ) );
105 names.insert( path.PathHumanReadable() );
106 }
107
108 BOOST_CHECK( names.contains( "/First Subsheet/" ) );
109 BOOST_CHECK( names.contains( "/First Subsheet/Sub2/" ) );
110 }
111 }
112
113 const wxString variant = wxS( "Simulation exclusion" );
114 schematic->AddVariant( variant );
115 SCH_SHEET_PATH parent = *selected;
116 parent.pop_back();
117
118 for( bool published : { false, true } )
119 {
120 enabled = published;
121
122 for( bool baseExcluded : { false, true } )
123 {
124 selected->Last()->SetExcludedFromSim( baseExcluded );
125 selected->Last()->SetExcludedFromSim( !baseExcluded, &parent, variant );
126
127 for( const wxString& active : { wxString(), variant } )
128 {
129 schematic->SetCurrentVariant( active );
130 const auto sheets = exporter.SelectedSheets();
131 const bool excluded = active.IsEmpty() ? baseExcluded : !baseExcluded;
132 BOOST_CHECK_EQUAL( sheets.size(), excluded ? 0 : 2 );
133 }
134 }
135 }
136}
137
138BOOST_AUTO_TEST_CASE( SpiceGroundNamesIgnorePowerScope )
139{
140 auto& enabled = const_cast<ADVANCED_CFG&>( ADVANCED_CFG::GetCfg() ).m_ConnectivityEngine;
141 SCOPED_SET_RESET restore( enabled, enabled );
142
143 for( bool published : { false, true } )
144 {
145 enabled = published;
146
147 for( bool local : { false, true } )
148 {
149 for( const wxString& name : { wxString( "0" ), wxString( "GND" ), wxString( "gNd" ) } )
150 {
151 BOOST_TEST_CONTEXT( "published=" << published << ", local=" << local << ", name=" << name )
152 {
153 SETTINGS_MANAGER settings;
154 std::unique_ptr<SCHEMATIC> schematic;
155 KI_TEST::LoadSchematic( settings, "ERC_dynamic_power_symbol_test", schematic );
156 SCH_SYMBOL* power = nullptr;
157
158 for( const SCH_SHEET_PATH& path : schematic->Hierarchy() )
159 {
160 if( path.size() < 2 )
161 continue;
162
163 for( SCH_ITEM* item : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
164 {
165 auto* symbol = static_cast<SCH_SYMBOL*>( item );
166
167 if( symbol->IsPower()
168 && symbol->GetField( FIELD_T::VALUE )->GetText().StartsWith( "REF" ) )
169 power = symbol;
170 }
171 }
172
173 BOOST_REQUIRE( power );
174 power->GetField( FIELD_T::VALUE )->SetText( name );
175
176 if( local )
177 power->GetLibSymbolRef()->SetLocalPower();
178 else
180
181 NETLIST_EXPORTER_SPICE exporter( schematic.get(), nullptr );
183 BOOST_REQUIRE_MESSAGE( exporter.ReadSchematicAndLibraries( 0, reporter ), reporter.GetMessages() );
184 const auto nets = exporter.GetNets();
185 BOOST_CHECK( nets.contains( name ) );
186 BOOST_CHECK( std::none_of( nets.begin(), nets.end(), [&]( const wxString& net )
187 { return net.Lower().EndsWith( wxS( "/" ) + name.Lower() ); } ) );
188 }
189 }
190 }
191 }
192}
193
194
195using PUBLISHED_EXPORTERS = boost::mpl::list<NETLIST_EXPORTER_PADS, NETLIST_EXPORTER_CADSTAR>;
196
197BOOST_AUTO_TEST_CASE_TEMPLATE( UsesPublishedNetsWithoutLegacyGraph, EXPORTER, PUBLISHED_EXPORTERS )
198{
199 auto& enabled = const_cast<ADVANCED_CFG&>( ADVANCED_CFG::GetCfg() ).m_ConnectivityEngine;
200 SCOPED_SET_RESET restore( enabled, enabled );
201
202 for( const auto& [fixture, expectsSignals] :
203 { std::pair{ "issue7203", false },
204 std::pair{ "netlists/hierarchy_aliases/hierarchy_aliases", true },
205 std::pair{ "netlists/video/video", true } } )
206 {
207 BOOST_TEST_CONTEXT( fixture )
208 {
209 enabled = false;
210 SETTINGS_MANAGER settings;
211 std::unique_ptr<SCHEMATIC> schematic;
212 KI_TEST::LoadSchematic( settings, fixture, schematic );
213 auto exportText = [&]()
214 {
215 KI_TEST::SCOPED_TEMP_DIR directory( "connectivity-published-export" );
216 const wxString path = directory.PathStr() + "/netlist.net";
218 EXPORTER exporter( schematic.get(), nullptr );
219 BOOST_REQUIRE_MESSAGE( exporter.WriteNetlist( path, 0, reporter ), reporter.GetMessages() );
220 wxFFile file( path, "r" );
221 BOOST_REQUIRE( file.IsOpened() );
222 wxString text;
223 BOOST_REQUIRE( file.ReadAll( &text ) );
224
225 if constexpr( std::is_same_v<EXPORTER, NETLIST_EXPORTER_CADSTAR> )
226 {
227 const size_t start = text.find( ".TIM " );
228 BOOST_REQUIRE( start != wxString::npos );
229 const size_t end = text.find( '\n', start );
230 BOOST_REQUIRE( end != wxString::npos );
231 text.erase( start, end - start );
232 }
233
234 return text;
235 };
236 const wxString expected = exportText();
237 const wxString marker = std::is_same_v<EXPORTER, NETLIST_EXPORTER_PADS> ? "*SIGNAL*" : ".ADD_TER";
238 BOOST_CHECK_EQUAL( expected.Contains( marker ), expectsSignals );
239 schematic->ConnectionGraph()->Reset();
240 schematic->Connectivity().Clear();
241 BOOST_REQUIRE( schematic->ConnectionGraph()->GetNetMap().empty() );
242 enabled = true;
243 const wxString actual = exportText();
245 }
246 }
247}
248
249BOOST_AUTO_TEST_CASE( AllegroUsesPublishedNetsAndPreservesDeviceFiles )
250{
251 auto& enabled = const_cast<ADVANCED_CFG&>( ADVANCED_CFG::GetCfg() ).m_ConnectivityEngine;
252 SCOPED_SET_RESET restore( enabled, enabled );
253
254 for( const char* fixture : { "issue7203", "netlists/hierarchy_aliases/hierarchy_aliases",
255 "netlists/video/video" } )
256 {
257 BOOST_TEST_CONTEXT( fixture )
258 {
259 enabled = false;
260 SETTINGS_MANAGER settings;
261 std::unique_ptr<SCHEMATIC> schematic;
262 KI_TEST::LoadSchematic( settings, fixture, schematic );
263 auto exportFiles = [&]()
264 {
265 KI_TEST::SCOPED_TEMP_DIR temp( "connectivity-allegro" );
266 const wxString directory = temp.PathStr();
268 NETLIST_EXPORTER_ALLEGRO exporter( schematic.get(), nullptr );
269 BOOST_REQUIRE_MESSAGE( exporter.WriteNetlist( directory + "/netlist.net", 0, reporter ),
270 reporter.GetMessages() );
271 wxArrayString paths;
272 wxDir::GetAllFiles( directory, &paths );
273 std::map<wxString, wxString> result;
274
275 for( const wxString& path : paths )
276 {
277 wxFFile file( path, "r" );
278 BOOST_REQUIRE( file.IsOpened() );
279 wxString text;
280 BOOST_REQUIRE( file.ReadAll( &text ) );
281 const wxString relative = path.Mid( directory.length() + 1 );
282
283 if( relative == "netlist.net" )
284 {
285 const size_t start = text.find( "(Date: " );
286 BOOST_REQUIRE( start != wxString::npos );
287 const size_t end = text.find( '\n', start );
288 BOOST_REQUIRE( end != wxString::npos );
289 text.erase( start, end - start );
290 }
291
292 result.emplace( relative, text );
293 }
294
295 BOOST_REQUIRE_GT( result.size(), 1u );
296 return result;
297 };
298 const auto expected = exportFiles();
299 schematic->ConnectionGraph()->Reset();
300 schematic->Connectivity().Clear();
301 BOOST_REQUIRE( schematic->ConnectionGraph()->GetNetMap().empty() );
302 enabled = true;
303 const auto actual = exportFiles();
304 BOOST_REQUIRE_EQUAL( actual.size(), expected.size() );
305
306 for( const auto& [path, text] : expected )
307 {
309 {
310 const auto found = actual.find( path );
311 BOOST_REQUIRE( found != actual.end() );
312 BOOST_CHECK_EQUAL( found->second, text );
313 }
314 }
315 }
316 }
317}
318
319BOOST_AUTO_TEST_CASE( PcbFormattingAndFileExportRebuildUnnotifiedSourceChanges )
320{
321 struct UNNOTIFIED_LABEL : SCH_LABEL
322 {
323 explicit UNNOTIFIED_LABEL( const SCH_LABEL& source ) : SCH_LABEL( source ) {}
324
325 void cacheShownText() override { EDA_TEXT::cacheShownText(); }
326 };
327
328 auto& enabled = const_cast<ADVANCED_CFG&>( ADVANCED_CFG::GetCfg() ).m_ConnectivityEngine;
329 SCOPED_SET_RESET restore( enabled, true );
330 SETTINGS_MANAGER settings;
331 std::unique_ptr<SCHEMATIC> schematic;
332 KI_TEST::LoadSchematic( settings, "issue7203", schematic );
333 SCH_SCREEN& screen = *schematic->Hierarchy().front().LastScreen();
334 auto labels = screen.Items().OfType( SCH_LABEL_T );
335 BOOST_REQUIRE( labels.begin() != labels.end() );
336 auto* native = static_cast<SCH_LABEL*>( *labels.begin() );
337 auto replacement = std::make_unique<UNNOTIFIED_LABEL>( *native );
338 screen.Remove( native, false );
339 std::unique_ptr<SCH_LABEL> original( native );
340 auto* label = replacement.get();
341 screen.Append( replacement.release() );
342 schematic->Connectivity().Update( *schematic );
343 schematic->ConnectionGraph()->Reset();
344 const auto revision = screen.ConnectivityRevision();
345 label->EDA_TEXT::SetText( "EXPORT_FORMAT_FRESH" );
346 BOOST_REQUIRE_EQUAL( screen.ConnectivityRevision(), revision );
347 NETLIST_EXPORTER_KICAD exporter( schematic.get(), nullptr );
348 STRING_FORMATTER formatter;
349 BOOST_REQUIRE_NO_THROW( exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD ) );
350 BOOST_CHECK( formatter.GetString().find( "EXPORT_FORMAT_FRESH" ) != std::string::npos );
351 const auto nextRevision = screen.ConnectivityRevision();
352 label->EDA_TEXT::SetText( "EXPORT_FILE_FRESH" );
353 BOOST_REQUIRE_EQUAL( screen.ConnectivityRevision(), nextRevision );
354 KI_TEST::SCOPED_TEMP_DIR directory( "connectivity-pcb-export" );
355 const wxString path = directory.PathStr() + "/netlist.net";
357 BOOST_REQUIRE_MESSAGE( exporter.WriteNetlist( path, 0, reporter ), reporter.GetMessages() );
358 wxFFile file( path, "r" );
359 BOOST_REQUIRE( file.IsOpened() );
360 wxString text;
361 BOOST_REQUIRE( file.ReadAll( &text ) );
362 BOOST_CHECK( text.Contains( "EXPORT_FILE_FRESH" ) );
363 BOOST_CHECK( !text.Contains( "EXPORT_FORMAT_FRESH" ) );
364}
365
366BOOST_AUTO_TEST_CASE( ExportRefreshesSymbolRuleAreaMembership )
367{
368 auto& enabled = const_cast<ADVANCED_CFG&>( ADVANCED_CFG::GetCfg() ).m_ConnectivityEngine;
369 SCOPED_SET_RESET restore( enabled, enabled );
370
371 for( bool engine : { false, true } )
372 {
373 BOOST_TEST_CONTEXT( "engine=" << engine )
374 {
375 enabled = engine;
376 SETTINGS_MANAGER settings;
377 std::unique_ptr<SCHEMATIC> schematic;
378 KI_TEST::LoadSchematic( settings, "netlists/multinetclasses/multinetclasses", schematic );
379 const auto sheet = schematic->Hierarchy().front();
380 SCH_SCREEN& screen = *sheet.LastScreen();
381 SCH_SYMBOL* symbol = nullptr;
382
383 for( SCH_ITEM* item : screen.Items().OfType( SCH_SYMBOL_T ) )
384 {
385 auto* candidate = static_cast<SCH_SYMBOL*>( item );
386
387 if( !candidate->IsPower() && !candidate->GetRef( &sheet ).StartsWith( "#" ) )
388 {
389 symbol = candidate;
390 break;
391 }
392 }
393
394 BOOST_REQUIRE( symbol );
395 auto areas = screen.Items().OfType( SCH_RULE_AREA_T );
396 BOOST_REQUIRE( areas.begin() != areas.end() );
397 auto* area = static_cast<SCH_RULE_AREA*>( *areas.begin() );
398 screen.Remove( symbol, false );
399 symbol->SetPosition( area->GetBoundingBox().Centre() );
400 screen.Append( symbol );
401 std::unordered_set<SCH_SCREEN*> screens{ &screen };
402 SCH_RULE_AREA::UpdateRuleAreasInScreens( screens, nullptr );
403 BOOST_REQUIRE( symbol->GetRuleAreaCache().contains( area ) );
404 const VECTOR2I originalPosition = symbol->GetPosition();
405 area->SetDNP( true );
406 symbol->SetDNP( false, &sheet );
407 symbol->SetPosition( VECTOR2I( -100000000, -100000000 ) );
408 BOOST_REQUIRE( symbol->ResolveDNP( &sheet ) );
409 const wxString reference = symbol->GetRef( &sheet );
410 KI_TEST::SCOPED_TEMP_DIR directory( "connectivity-export-areas" );
411 const wxString path = directory.PathStr() + "/netlist.xml";
412 NETLIST_EXPORTER_XML exporter( schematic.get(), nullptr );
413 auto exportDnp = [&]()
414 {
416 BOOST_REQUIRE_MESSAGE( exporter.WriteNetlist( path, 0, reporter ), reporter.GetMessages() );
417 wxXmlDocument document;
418 BOOST_REQUIRE( document.Load( path ) );
419 bool found = false;
420 bool dnp = false;
421
422 for( wxXmlNode* section = document.GetRoot()->GetChildren(); section; section = section->GetNext() )
423 {
424 if( section->GetName() != "components" )
425 continue;
426
427 for( wxXmlNode* component = section->GetChildren(); component; component = component->GetNext() )
428 {
429 if( component->GetAttribute( "ref" ) != reference )
430 continue;
431
432 found = true;
433
434 for( wxXmlNode* property = component->GetChildren(); property; property = property->GetNext() )
435 dnp |= property->GetName() == "property" && property->GetAttribute( "name" ) == "dnp";
436 }
437 }
438
439 BOOST_REQUIRE( found );
440 return dnp;
441 };
442
443 BOOST_CHECK( !exportDnp() );
444 BOOST_CHECK( !symbol->ResolveDNP( &sheet ) );
445 symbol->SetPosition( originalPosition );
446 BOOST_CHECK( exportDnp() );
447 BOOST_CHECK( symbol->ResolveDNP( &sheet ) );
448 }
449 }
450}
451
452BOOST_AUTO_TEST_CASE( FormattingFailureAllowsExporterReuse )
453{
454 struct FAILING_FORMATTER : STRING_FORMATTER
455 {
456 void write( const char*, int ) override
457 {
458 THROW_IO_ERROR( wxString( "Netlist output failed" ) );
459 }
460 } failing;
461
462 auto& enabled = const_cast<ADVANCED_CFG&>( ADVANCED_CFG::GetCfg() ).m_ConnectivityEngine;
463 SCOPED_SET_RESET restore( enabled, enabled );
464
465 for( bool engine : { false, true } )
466 {
467 BOOST_TEST_CONTEXT( "engine=" << engine )
468 {
469 enabled = engine;
470 SETTINGS_MANAGER settings;
471 std::unique_ptr<SCHEMATIC> schematic;
472 KI_TEST::LoadSchematic( settings, "issue7203", schematic );
473 NETLIST_EXPORTER_KICAD exporter( schematic.get(), nullptr );
474 BOOST_CHECK_EXCEPTION( exporter.Format( &failing, GNL_ALL | GNL_OPT_KICAD ), IO_ERROR,
475 []( const IO_ERROR& error )
476 {
477 return error.Problem().Contains( "Netlist output failed" );
478 } );
479 STRING_FORMATTER output;
480 BOOST_REQUIRE_NO_THROW( exporter.Format( &output, GNL_ALL | GNL_OPT_KICAD ) );
481 BOOST_CHECK( !output.GetString().empty() );
482 }
483 }
484}
485
486BOOST_AUTO_TEST_CASE( ExportRefreshesCommittedChainAfterNetRename )
487{
488 LOCALE_IO locale;
489 auto& enabled = const_cast<ADVANCED_CFG&>( ADVANCED_CFG::GetCfg() ).m_ConnectivityEngine;
490 SCOPED_SET_RESET restore( enabled, false );
491 SETTINGS_MANAGER settings;
492 std::unique_ptr<SCHEMATIC> schematic;
493 KI_TEST::LoadSchematic( settings, "net_chains_four_nets_labeled", schematic );
494 auto* graph = schematic->ConnectionGraph();
495 BOOST_REQUIRE( !graph->GetPotentialNetChains().empty() );
496 auto* chain = graph->CreateNetChainFromPotential( graph->GetPotentialNetChains().front().get(),
497 "EXPORT_CHAIN" );
499 SCH_LABEL* label = nullptr;
500 wxString oldName;
501
502 for( const SCH_SHEET_PATH& path : schematic->Hierarchy() )
503 {
504 for( SCH_ITEM* item : path.LastScreen()->Items().OfType( SCH_LABEL_T ) )
505 {
506 auto* candidate = static_cast<SCH_LABEL*>( item );
507 auto* connection = candidate->Connection( &path );
508
509 if( connection && chain->GetNets().contains( connection->Name() ) )
510 {
511 label = candidate;
512 oldName = connection->Name();
513 break;
514 }
515 }
516
517 if( label )
518 break;
519 }
520
521 BOOST_REQUIRE( label );
522 label->SetText( "EXPORT_CHAIN_RENAMED" );
523
524 for( bool usePublished : { true, false } )
525 {
526 BOOST_TEST_CONTEXT( "published=" << usePublished )
527 {
528 enabled = usePublished;
529 NETLIST_EXPORTER_XML exporter( schematic.get(), nullptr );
531 KI_TEST::SCOPED_TEMP_DIR directory( "connectivity-chain-export" );
532 const wxString file = directory.PathStr() + "/netlist.xml";
533 BOOST_REQUIRE_MESSAGE( exporter.WriteNetlist( file, GNL_OPT_KICAD, reporter ), reporter.GetMessages() );
534 wxXmlDocument document;
535 BOOST_REQUIRE( document.Load( file ) );
536 std::set<wxString> members;
537 auto collect = [&]( auto&& self, wxXmlNode* node ) -> void
538 {
539 for( ; node; node = node->GetNext() )
540 {
541 if( node->GetName() == "member" )
542 members.insert( node->GetAttribute( "net" ) );
543
544 self( self, node->GetChildren() );
545 }
546 };
547 collect( collect, document.GetRoot() );
548 BOOST_CHECK( members.contains( "/EXPORT_CHAIN_RENAMED" ) );
549 BOOST_CHECK( !members.contains( oldName ) );
550 }
551 }
552}
553
const char * name
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual void cacheShownText()
Definition eda_text.cpp:604
virtual void SetText(const wxString &aText)
Definition eda_text.cpp:236
EE_TYPE OfType(KICAD_T aType) const
Definition sch_rtree.h:248
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
wxString PathStr() const
Get the path to the temporary directory as a wxString.
Definition file_utils.h:62
void SetGlobalPower()
void SetLocalPower()
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
Generate a netlist compatible with Allegro.
bool WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter)
Write to specified output file.
Generate the KiCad netlist format supported by Pcbnew.
void Format(OUTPUTFORMATTER *aOutputFormatter, int aCtl)
Output this s-expression netlist into aOutputFormatter.
NETLIST_EXPORTER_SPICE(SCHEMATIC *aSchematic, KIWAY *aKiway)
SCH_SHEET_LIST BuildSheetList(unsigned aNetlistOptions=0) const
Return the paths of exported sheets (either all or the current one).
std::set< wxString > GetNets() const
Return the list of nets.
virtual bool ReadSchematicAndLibraries(unsigned aNetlistOptions, REPORTER &aReporter)
Process the schematic and Spice libraries to create net mapping and a list of SPICE_ITEMs.
Generate a generic XML based netlist file.
void SetText(const wxString &aText) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
const std::unordered_set< SCH_RULE_AREA * > & GetRuleAreaCache() const
Get the cache of rule areas enclosing this item.
Definition sch_item.h:733
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition sch_item.cpp:580
bool ResolveDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:446
void cacheShownText() override
SCH_LABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString)
static std::vector< std::pair< SCH_RULE_AREA *, SCH_SCREEN * > > UpdateRuleAreasInScreens(std::unordered_set< SCH_SCREEN * > &screens, KIGFX::SCH_VIEW *view)
Update all rule area connectvity / caches in the given sheet paths.
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
uint64_t ConnectivityRevision() const
The only change signal that the connectivity engine reads from this screen.
Definition sch_screen.h:181
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:122
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
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...
void pop_back()
Forwarded method from std::vector.
Schematic symbol object.
Definition sch_symbol.h:73
virtual void SetDNP(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void SetPosition(const VECTOR2I &aPosition) override
Definition sch_symbol.h:896
VECTOR2I GetPosition() const override
Definition sch_symbol.h:895
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition sch_symbol.h:182
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
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.
Implement an OUTPUTFORMATTER to a memory buffer.
Definition richio.h:430
void write(const char *aOutBuf, int aCount) override
Should be coded in the interface implementation (derived) classes.
Definition richio.cpp:518
const std::string & GetString()
Definition richio.h:453
A wrapper for reporting to a wxString object.
Definition reporter.h:242
bool m_ConnectivityEngine
Use the schematic connectivity engine instead of CONNECTION_GRAPH.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
std::string source
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
#define GNL_ALL
@ GNL_OPT_KICAD
@ VALUE
Field Value of part, i.e. "3.3K".
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(CurrentSheetExportPreservesFullInstancePaths)
BOOST_AUTO_TEST_CASE_TEMPLATE(UsesPublishedNetsWithoutLegacyGraph, EXPORTER, PUBLISHED_EXPORTERS)
boost::mpl::list< NETLIST_EXPORTER_PADS, NETLIST_EXPORTER_CADSTAR > PUBLISHED_EXPORTERS
BOOST_GLOBAL_FIXTURE(GlobalConfig)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
std::string path
IbisParser parser & reporter
VECTOR3I expected(15, 30, 45)
const SHAPE_LINE_CHAIN chain
VECTOR2I end
BOOST_TEST_CONTEXT("Test Clearance")
int actual
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
@ SCH_SYMBOL_T
Definition typeinfo.h:168
@ SCH_LABEL_T
Definition typeinfo.h:163
@ SCH_RULE_AREA_T
Definition typeinfo.h:166
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708