A few baby steps in trying to straighten out LTSPICE_SCHEMATIC::Load().
This commit is contained in:
parent
229dcde948
commit
3ba7e7e993
|
@ -36,64 +36,52 @@
|
||||||
void LTSPICE_SCHEMATIC::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet,
|
void LTSPICE_SCHEMATIC::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet,
|
||||||
const wxFileName& aLibraryFileName )
|
const wxFileName& aLibraryFileName )
|
||||||
{
|
{
|
||||||
std::vector<LTSPICE_FILE> sourceFiles;
|
|
||||||
std::map<wxString, wxString> mapOfAscFiles;
|
std::map<wxString, wxString> mapOfAscFiles;
|
||||||
std::map<wxString, wxString> mapOfAsyFiles;
|
std::map<wxString, wxString> mapOfAsyFiles;
|
||||||
|
|
||||||
|
GetAscAndAsyFilePaths( mapOfAscFiles, mapOfAsyFiles, aLibraryFileName );
|
||||||
|
|
||||||
m_schematic = aSchematic;
|
m_schematic = aSchematic;
|
||||||
|
|
||||||
std::queue<LTSPICE_FILE> ascFileQueue;
|
std::queue<wxString> ascFileQueue;
|
||||||
LTSPICE_FILE ascFileObject( aLibraryFileName.GetName(), { 0, 0 } );
|
ascFileQueue.push( aLibraryFileName.GetName().Lower() );
|
||||||
|
|
||||||
ascFileObject.Screen = aRootSheet->GetScreen();
|
LTSPICE_FILE rootAscFile( ascFileQueue.front(), { 0, 0 } );
|
||||||
|
|
||||||
ascFileQueue.push( ascFileObject );
|
rootAscFile.Sheet = aRootSheet;
|
||||||
|
rootAscFile.Screen = new SCH_SCREEN();
|
||||||
GetAscAndAsyFilePaths( mapOfAscFiles, mapOfAsyFiles, aLibraryFileName );
|
|
||||||
|
|
||||||
int parentSheetIndex = 0;
|
int parentSheetIndex = 0;
|
||||||
|
|
||||||
// Asc files who are subschematic in nature
|
// Asc files who are subschematic in nature
|
||||||
std::vector<LTSPICE_FILE> ascFiles;
|
std::vector<LTSPICE_FILE> ascFiles;
|
||||||
|
|
||||||
ascFileObject.Sheet = aRootSheet;
|
ascFiles.push_back( rootAscFile );
|
||||||
|
|
||||||
ascFileObject.Screen = new SCH_SCREEN();
|
|
||||||
|
|
||||||
ascFiles.push_back( ascFileObject );
|
|
||||||
|
|
||||||
// Map stores sheetName and sheet
|
|
||||||
std::map<wxString, SCH_SHEET*> ascSheetMap;
|
|
||||||
|
|
||||||
while( !ascFileQueue.empty() )
|
while( !ascFileQueue.empty() )
|
||||||
{
|
{
|
||||||
SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
|
SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
|
||||||
|
|
||||||
// Reading the .asc file
|
// Reading the .asc file
|
||||||
wxString fileIndex = ascFileQueue.front().ElementName;
|
wxString ascFilePath = mapOfAscFiles[ ascFileQueue.front() ];
|
||||||
wxString ascFilePath = mapOfAscFiles[fileIndex];
|
|
||||||
wxString buffer = SafeReadFile( ascFilePath, "r" );
|
wxString buffer = SafeReadFile( ascFilePath, "r" );
|
||||||
|
|
||||||
std::vector<LTSPICE_FILE> newSubSchematicElements;
|
std::vector<LTSPICE_FILE> newSubSchematicElements = GetSchematicElements( buffer );
|
||||||
|
|
||||||
// Getting the keywords to read
|
alg::delete_if( newSubSchematicElements,
|
||||||
sourceFiles = GetSchematicElements( buffer );
|
[&mapOfAscFiles]( const LTSPICE_FILE& ii )
|
||||||
|
|
||||||
SubSchematicCheck( sourceFiles, mapOfAscFiles, newSubSchematicElements );
|
|
||||||
|
|
||||||
for( unsigned int i = 0; i < newSubSchematicElements.size(); i++ )
|
|
||||||
{
|
{
|
||||||
newSubSchematicElements[i].ParentIndex = parentSheetIndex;
|
return mapOfAscFiles[ii.ElementName].IsEmpty();
|
||||||
|
} );
|
||||||
|
|
||||||
newSubSchematicElements[i].Screen = screen;
|
for( LTSPICE_FILE& newSubSchematicElement : newSubSchematicElements )
|
||||||
|
{
|
||||||
|
newSubSchematicElement.ParentIndex = parentSheetIndex;
|
||||||
|
newSubSchematicElement.Screen = screen;
|
||||||
|
newSubSchematicElement.Sheet = new SCH_SHEET();
|
||||||
|
|
||||||
SCH_SHEET* sheet = new SCH_SHEET();
|
ascFileQueue.push( newSubSchematicElement.ElementName );
|
||||||
|
ascFiles.push_back( newSubSchematicElement );
|
||||||
newSubSchematicElements[i].Sheet = sheet;
|
|
||||||
ascSheetMap[newSubSchematicElements[i].ElementName] = sheet;
|
|
||||||
|
|
||||||
ascFileQueue.push( newSubSchematicElements[i] );
|
|
||||||
ascFiles.push_back( newSubSchematicElements[i] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ascFileQueue.pop();
|
ascFileQueue.pop();
|
||||||
|
@ -107,7 +95,7 @@ void LTSPICE_SCHEMATIC::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet,
|
||||||
wxString buffer = SafeReadFile( mapOfAscFiles[ascFiles[i].ElementName], wxS( "r" ) );
|
wxString buffer = SafeReadFile( mapOfAscFiles[ascFiles[i].ElementName], wxS( "r" ) );
|
||||||
|
|
||||||
// Getting the keywords to read
|
// Getting the keywords to read
|
||||||
sourceFiles = GetSchematicElements( buffer );
|
std::vector<LTSPICE_FILE> sourceFiles = GetSchematicElements( buffer );
|
||||||
|
|
||||||
m_fileCache[ wxS( "asyFiles" ) ] = ReadAsyFiles( sourceFiles, mapOfAsyFiles );
|
m_fileCache[ wxS( "asyFiles" ) ] = ReadAsyFiles( sourceFiles, mapOfAsyFiles );
|
||||||
m_fileCache[ wxS( "ascFiles" ) ][ wxS( "parentFile" ) ] = buffer;
|
m_fileCache[ wxS( "ascFiles" ) ][ wxS( "parentFile" ) ] = buffer;
|
||||||
|
@ -177,18 +165,6 @@ void LTSPICE_SCHEMATIC::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LTSPICE_SCHEMATIC::SubSchematicCheck( std::vector<LTSPICE_FILE>& aSchematicElementsArray,
|
|
||||||
std::map<wxString, wxString>& aMapOfAscFiles,
|
|
||||||
std::vector<LTSPICE_FILE>& aSubSchematicSet )
|
|
||||||
{
|
|
||||||
for( const LTSPICE_FILE& it : aSchematicElementsArray )
|
|
||||||
{
|
|
||||||
if( aMapOfAscFiles[it.ElementName] != "" )
|
|
||||||
aSubSchematicSet.push_back( it );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LTSPICE_SCHEMATIC::GetAscAndAsyFilePaths( std::map<wxString, wxString>& aMapOfAscFiles,
|
void LTSPICE_SCHEMATIC::GetAscAndAsyFilePaths( std::map<wxString, wxString>& aMapOfAscFiles,
|
||||||
std::map<wxString, wxString>& aMapOfAsyFiles,
|
std::map<wxString, wxString>& aMapOfAsyFiles,
|
||||||
const wxFileName& parentFileName )
|
const wxFileName& parentFileName )
|
||||||
|
|
|
@ -294,17 +294,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet, const wxFileName& aLibraryFileName );
|
void Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet, const wxFileName& aLibraryFileName );
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to check if the given symbol is subschematic or not.
|
|
||||||
*
|
|
||||||
* @param aSchematicElementsArray array which stores which elements names.
|
|
||||||
* @param aMapOfAscFiles map of string containing content from asc files.
|
|
||||||
* @param aSubSchematicList list of subschematic elements.
|
|
||||||
*/
|
|
||||||
void SubSchematicCheck( std::vector<LTSPICE_FILE>& aSchematicElementsArray,
|
|
||||||
std::map<wxString, wxString>& aMapOfAscFiles,
|
|
||||||
std::vector<LTSPICE_FILE>& aSubSchematicList );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to get file path for Asc and Asy files.
|
* Used to get file path for Asc and Asy files.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue