CADSTAR Schematic Archive Importer: Import common fields visibilities
Import field visibilities for Ref, Value and Part Name Also fix incorrect loading of designator from previous commit
This commit is contained in:
parent
f559e94b00
commit
cc27c31ab0
|
@ -2243,6 +2243,30 @@ void CADSTAR_ARCHIVE_PARSER::ATTRCOLORS::Parse( XNODE* aNode, PARSER_CONTEXT* aC
|
|||
}
|
||||
|
||||
|
||||
void CADSTAR_ARCHIVE_PARSER::PARTNAMECOL::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
||||
{
|
||||
wxASSERT( aNode->GetName() == wxT( "PARTNAMECOL" ) );
|
||||
|
||||
Color = GetXmlAttributeIDString( aNode, 0 );
|
||||
|
||||
XNODE* cNode = aNode->GetChildren();
|
||||
|
||||
for( ; cNode; cNode = cNode->GetNext() )
|
||||
{
|
||||
wxString cNodeName = cNode->GetName();
|
||||
|
||||
if( cNodeName == wxT( "INVISIBLE" ) )
|
||||
{
|
||||
IsVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CADSTAR_ARCHIVE_PARSER::InsertAttributeAtEnd( XNODE* aNode, wxString aValue )
|
||||
{
|
||||
wxString result;
|
||||
|
|
|
@ -1246,6 +1246,14 @@ public:
|
|||
};
|
||||
|
||||
|
||||
struct PARTNAMECOL : PARSER
|
||||
{
|
||||
COLOR_ID Color;
|
||||
bool IsVisible = true;
|
||||
|
||||
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
||||
};
|
||||
|
||||
///////////////////////
|
||||
// HELPER FUNCTIONS: //
|
||||
///////////////////////
|
||||
|
|
|
@ -376,6 +376,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
|
|||
|
||||
loadSymbolFieldAttribute( sym.PartRef.AttrLoc, symOrientDeciDeg,
|
||||
sym.Mirror, partField );
|
||||
|
||||
partField->SetVisible( SymbolPartNameColor.IsVisible );
|
||||
}
|
||||
|
||||
int fieldIdx = FIELD1;
|
||||
|
@ -456,9 +458,15 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
|
|||
symbolDef.TextLocations.at( SIGNALNAME_ORIGIN_ATTRID );
|
||||
kiPart->GetValueField().SetPosition(
|
||||
getKiCadLibraryPoint( signameOrigin.Position, symbolDef.Origin ) );
|
||||
kiPart->GetValueField().SetVisible( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
kiPart->GetValueField().SetVisible( false );
|
||||
}
|
||||
|
||||
kiPart->GetReferenceField().SetText( "#PWR" );
|
||||
kiPart->GetReferenceField().SetVisible( false );
|
||||
( *mPlugin )->SaveSymbol( mLibraryFileName.GetFullPath(), kiPart );
|
||||
mPowerSymLibMap.insert( { symID, kiPart } );
|
||||
}
|
||||
|
@ -1142,6 +1150,10 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
|
|||
field->SetUnit( gateNumber );
|
||||
}
|
||||
|
||||
// Hide the value field for now (it might get unhidden if an attribute exists in the cadstar
|
||||
// design with the text "Value"
|
||||
aPart->GetValueField().SetVisible( false );
|
||||
|
||||
if( symbol.TextLocations.find( PART_NAME_ATTRID ) != symbol.TextLocations.end() )
|
||||
{
|
||||
TEXT_LOCATION textLoc = symbol.TextLocations.at( PART_NAME_ATTRID );
|
||||
|
@ -1166,6 +1178,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
|
|||
}
|
||||
|
||||
field->SetUnit( gateNumber );
|
||||
field->SetVisible( SymbolPartNameColor.IsVisible );
|
||||
}
|
||||
|
||||
if( aCadstarPart )
|
||||
|
@ -1402,6 +1415,11 @@ SCH_COMPONENT* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(
|
|||
|
||||
SCH_COMPONENT* component = new SCH_COMPONENT( *aKiCadPart, libId, &sheetpath, unit );
|
||||
|
||||
if( aCadstarSymbol.IsComponent )
|
||||
{
|
||||
component->SetRef( &sheetpath, aCadstarSymbol.ComponentRef.Designator );
|
||||
}
|
||||
|
||||
component->SetPosition( getKiCadPoint( aCadstarSymbol.Origin ) );
|
||||
|
||||
double compAngleDeciDeg = getAngleTenthDegree( aCadstarSymbol.OrientAngle );
|
||||
|
@ -1438,15 +1456,6 @@ SCH_COMPONENT* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
wxString currentSheetPath = sheetpath.PathAsString() + component->m_Uuid.AsString();
|
||||
|
||||
if( aCadstarSymbol.IsComponent )
|
||||
{
|
||||
component->AddHierarchicalReference( currentSheetPath,
|
||||
aCadstarSymbol.ComponentRef.Designator,
|
||||
getKiCadUnitNumberFromGate( aCadstarSymbol.GateID ) );
|
||||
}
|
||||
|
||||
kiSheet->GetScreen()->Append( component );
|
||||
|
||||
return component;
|
||||
|
|
|
@ -83,8 +83,7 @@ void CADSTAR_SCH_ARCHIVE_PARSER::Parse()
|
|||
else if( cNode->GetName() == wxT( "DISPLAY" ) )
|
||||
{
|
||||
// For now only interested in Attribute visibilities, in order to set field visibilities
|
||||
// in the importer desing
|
||||
|
||||
// in the imported design
|
||||
XNODE* subNode = cNode->GetChildren();
|
||||
|
||||
for( ; subNode; subNode = subNode->GetNext() )
|
||||
|
@ -93,6 +92,24 @@ void CADSTAR_SCH_ARCHIVE_PARSER::Parse()
|
|||
{
|
||||
AttrColors.Parse( subNode, &mContext );
|
||||
}
|
||||
else if( subNode->GetName() == wxT( "SCMITEMCOLORS" ) )
|
||||
{
|
||||
XNODE* sub2Node = subNode->GetChildren();
|
||||
|
||||
for( ; sub2Node; sub2Node = sub2Node->GetNext() )
|
||||
{
|
||||
if( sub2Node->GetName() == wxT( "SYMCOL" ) )
|
||||
{
|
||||
XNODE* sub3Node = sub2Node->GetChildren();
|
||||
|
||||
for( ; sub3Node; sub3Node = sub3Node->GetNext() )
|
||||
{
|
||||
if( sub3Node->GetName() == wxT( "PARTNAMECOL" ) )
|
||||
SymbolPartNameColor.Parse( sub3Node, &mContext );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No design information here
|
||||
|
|
|
@ -446,6 +446,7 @@ public:
|
|||
SHEETS Sheets;
|
||||
SCHEMATIC Schematic;
|
||||
ATTRCOLORS AttrColors;
|
||||
PARTNAMECOL SymbolPartNameColor;
|
||||
|
||||
double KiCadUnitMultiplier; ///<Use this value to convert units in this CSA file to KiCad units
|
||||
|
||||
|
|
Loading…
Reference in New Issue