diff --git a/common/plugins/cadstar/cadstar_archive_parser.cpp b/common/plugins/cadstar/cadstar_archive_parser.cpp index 5316d50eab..5deb8fb968 100644 --- a/common/plugins/cadstar/cadstar_archive_parser.cpp +++ b/common/plugins/cadstar/cadstar_archive_parser.cpp @@ -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; diff --git a/common/plugins/cadstar/cadstar_archive_parser.h b/common/plugins/cadstar/cadstar_archive_parser.h index 5bd5c446ae..e4a2634381 100644 --- a/common/plugins/cadstar/cadstar_archive_parser.h +++ b/common/plugins/cadstar/cadstar_archive_parser.h @@ -1246,6 +1246,14 @@ public: }; + struct PARTNAMECOL : PARSER + { + COLOR_ID Color; + bool IsVisible = true; + + void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override; + }; + /////////////////////// // HELPER FUNCTIONS: // /////////////////////// diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index 8db95df73f..66b2df9edf 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -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; diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.cpp index cdbc83e016..9f51c21982 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.cpp @@ -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 diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.h b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.h index 82644cde86..92eb4b7c0e 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.h +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_parser.h @@ -446,6 +446,7 @@ public: SHEETS Sheets; SCHEMATIC Schematic; ATTRCOLORS AttrColors; + PARTNAMECOL SymbolPartNameColor; double KiCadUnitMultiplier; ///