KiCad PCB EDA Suite
eeschema_test_utils.cpp File Reference
#include "eeschema_test_utils.h"
#include <cstdlib>
#include <memory>
#include <eeschema/sch_io_mgr.h>
#include <eeschema/sch_screen.h>
#include <eeschema/schematic.h>
#include <eeschema/connection_graph.h>

Go to the source code of this file.

Macros

#define QA_EESCHEMA_DATA_LOCATION   "???"
 

Functions

std::unique_ptr< SCHEMATICReadSchematicFromFile (const std::string &aFilename)
 

Macro Definition Documentation

◆ QA_EESCHEMA_DATA_LOCATION

#define QA_EESCHEMA_DATA_LOCATION   "???"

Definition at line 36 of file eeschema_test_utils.cpp.

Function Documentation

◆ ReadSchematicFromFile()

std::unique_ptr<SCHEMATIC> ReadSchematicFromFile ( const std::string &  aFilename)

Definition at line 63 of file eeschema_test_utils.cpp.

64 {
65  auto pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD );
66  std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>( nullptr );
67 
68  schematic->Reset();
69  schematic->SetRoot( pi->Load( aFilename, schematic.get() ) );
70  schematic->CurrentSheet().push_back( &schematic->Root() );
71 
72  SCH_SCREENS screens( schematic->Root() );
73 
74  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
75  screen->UpdateLocalLibSymbolLinks();
76 
77  SCH_SHEET_LIST sheets = schematic->GetSheets();
78 
79  // Restore all of the loaded symbol instances from the root sheet screen.
80  sheets.UpdateSymbolInstances( schematic->RootScreen()->GetSymbolInstances() );
81 
82  sheets.AnnotatePowerSymbols();
83 
84  // NOTE: This is required for multi-unit symbols to be correct
85  // Normally called from SCH_EDIT_FRAME::FixupJunctions() but could be refactored
86  for( SCH_SHEET_PATH& sheet : sheets )
87  sheet.UpdateAllScreenReferences();
88 
89  // NOTE: SchematicCleanUp is not called; QA schematics must already be clean or else
90  // SchematicCleanUp must be freed from its UI dependencies.
91 
92  schematic->ConnectionGraph()->Recalculate( sheets, true );
93 
94  return schematic;
95 }
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 UpdateSymbolInstances(const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
void AnnotatePowerSymbols()
Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:549

References SCH_SHEET_LIST::AnnotatePowerSymbols(), and SCH_SHEET_LIST::UpdateSymbolInstances().