CADSTAR Schematic Archive Importer: Load Schematic Text Variables to KiCad project
This commit is contained in:
parent
03a23db4f7
commit
a5118df44c
|
@ -91,6 +91,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( ::SCHEMATIC* aSchematic, ::SCH_SHEET* aRo
|
||||||
loadFigures();
|
loadFigures();
|
||||||
loadTexts();
|
loadTexts();
|
||||||
loadDocumentationSymbols();
|
loadDocumentationSymbols();
|
||||||
|
loadTextVariables();
|
||||||
|
|
||||||
if( Schematic.VariantHierarchy.Variants.size() > 0 )
|
if( Schematic.VariantHierarchy.Variants.size() > 0 )
|
||||||
{
|
{
|
||||||
|
@ -911,6 +912,66 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CADSTAR_SCH_ARCHIVE_LOADER::loadTextVariables()
|
||||||
|
{
|
||||||
|
auto findAndReplaceTextField = [&]( TEXT_FIELD_NAME aField, wxString aValue ) {
|
||||||
|
if( mContext.TextFieldToValuesMap.find( aField ) != mContext.TextFieldToValuesMap.end() )
|
||||||
|
{
|
||||||
|
if( mContext.TextFieldToValuesMap.at( aField ) != aValue )
|
||||||
|
{
|
||||||
|
mContext.TextFieldToValuesMap.at( aField ) = aValue;
|
||||||
|
mContext.InconsistentTextFields.insert( aField );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mContext.TextFieldToValuesMap.insert( { aField, aValue } );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
PROJECT* pj = &mSchematic->Prj();
|
||||||
|
|
||||||
|
if( pj )
|
||||||
|
{
|
||||||
|
std::map<wxString, wxString>& txtVars = pj->GetTextVars();
|
||||||
|
|
||||||
|
// Most of the design text fields can be derived from other elements
|
||||||
|
if( Schematic.VariantHierarchy.Variants.size() > 0 )
|
||||||
|
{
|
||||||
|
VARIANT loadedVar = Schematic.VariantHierarchy.Variants.begin()->second;
|
||||||
|
|
||||||
|
findAndReplaceTextField( TEXT_FIELD_NAME::VARIANT_NAME, loadedVar.Name );
|
||||||
|
findAndReplaceTextField( TEXT_FIELD_NAME::VARIANT_DESCRIPTION, loadedVar.Description );
|
||||||
|
}
|
||||||
|
|
||||||
|
findAndReplaceTextField( TEXT_FIELD_NAME::DESIGN_TITLE, Header.JobTitle );
|
||||||
|
|
||||||
|
for( std::pair<TEXT_FIELD_NAME, wxString> txtvalue : mContext.TextFieldToValuesMap )
|
||||||
|
{
|
||||||
|
wxString varName = CadstarToKicadFieldsMap.at( txtvalue.first );
|
||||||
|
wxString varValue = txtvalue.second;
|
||||||
|
|
||||||
|
txtVars.insert( { varName, varValue } );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( std::pair<wxString, wxString> txtvalue : mContext.FilenamesToTextMap )
|
||||||
|
{
|
||||||
|
wxString varName = txtvalue.first;
|
||||||
|
wxString varValue = txtvalue.second;
|
||||||
|
|
||||||
|
txtVars.insert( { varName, varValue } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxLogError( _( "Text Variables could not be set as there is no project attached." ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdefID,
|
void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdefID,
|
||||||
const PART* aCadstarPart, const GATE_ID& aGateID, LIB_PART* aPart )
|
const PART* aCadstarPart, const GATE_ID& aGateID, LIB_PART* aPart )
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,6 +108,7 @@ private:
|
||||||
void loadFigures();
|
void loadFigures();
|
||||||
void loadTexts();
|
void loadTexts();
|
||||||
void loadDocumentationSymbols();
|
void loadDocumentationSymbols();
|
||||||
|
void loadTextVariables();
|
||||||
|
|
||||||
//Helper Functions for loading sheets
|
//Helper Functions for loading sheets
|
||||||
void loadSheetAndChildSheets( LAYER_ID aCadstarSheetID, wxPoint aPosition, wxSize aSheetSize,
|
void loadSheetAndChildSheets( LAYER_ID aCadstarSheetID, wxPoint aPosition, wxSize aSheetSize,
|
||||||
|
|
Loading…
Reference in New Issue