diff --git a/common/plugins/cadstar/cadstar_archive_parser.cpp b/common/plugins/cadstar/cadstar_archive_parser.cpp index 185469956e..80d40f1d8d 100644 --- a/common/plugins/cadstar/cadstar_archive_parser.cpp +++ b/common/plugins/cadstar/cadstar_archive_parser.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include // Ratio derived from CADSTAR default font. See doxygen comment in cadstar_archive_parser.h @@ -2546,6 +2547,16 @@ std::vector CADSTAR_ARCHIVE_PARSER::ParseAllChil } +wxString CADSTAR_ARCHIVE_PARSER::HandleTextOverbar( wxString aCadstarString ) +{ + wxString escapedText = aCadstarString; + + escapedText.Replace( wxT( "'" ), wxT( "~" ) ); + + return ConvertToNewOverbarNotation( escapedText ); +} + + void CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment( EDA_TEXT* aKiCadTextItem ) { if( !aKiCadTextItem->GetText().IsEmpty() ) diff --git a/common/plugins/cadstar/cadstar_archive_parser.h b/common/plugins/cadstar/cadstar_archive_parser.h index 1baef29546..20f97eb2b1 100644 --- a/common/plugins/cadstar/cadstar_archive_parser.h +++ b/common/plugins/cadstar/cadstar_archive_parser.h @@ -1368,6 +1368,13 @@ public: static std::vector ParseAllChildCutouts( XNODE* aNode, PARSER_CONTEXT* aContext, bool aTestAllChildNodes = false ); + /** + * @brief Convert a string with CADSTAR overbar characters to equivalent in KiCad + * @param aCadstarString Input string + * @return KiCad string with overbar characters + */ + static wxString HandleTextOverbar( wxString aCadstarString ); + /** * Corrects the position of a text element that had NO_ALIGNMENT in CADSTAR. Assumes that the * provided text element has been initialised with a position and orientation. diff --git a/common/plugins/eagle/eagle_parser.cpp b/common/plugins/eagle/eagle_parser.cpp index d7965f652a..5d091207ad 100644 --- a/common/plugins/eagle/eagle_parser.cpp +++ b/common/plugins/eagle/eagle_parser.cpp @@ -41,10 +41,9 @@ wxString escapeName( const wxString& aNetName ) { wxString ret( aNetName ); - ret.Replace( "~", "~~" ); ret.Replace( "!", "~" ); - return ret; + return ConvertToNewOverbarNotation( ret ); } diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index 9ab665dce2..e1418a3796 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -680,7 +680,10 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadBusses() m_busesMap.insert( { bus.ID, kiBusAlias } ); SCH_LABEL* label = new SCH_LABEL(); - label->SetText( wxT( "{" ) + bus.Name + wxT( "}" ) ); + + wxString busname = HandleTextOverbar( bus.Name ); + + label->SetText( wxT( "{" ) + busname + wxT( "}" ) ); label->SetVisible( true ); screen->Append( label ); @@ -730,6 +733,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadBusses() bus.BusLabel.Alignment, bus.BusLabel.Justification ); + // Re-set bus name as it might have been "double-escaped" after applyTextSettings + label->SetText( wxT( "{" ) + busname + wxT( "}" ) ); + // Note orientation of the bus label will be determined in loadNets // (the position of the wire will determine how best to place the bus label) } @@ -750,6 +756,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets() if( netName.IsEmpty() ) netName = wxString::Format( "$%ld", net.SignalNum ); + netName = HandleTextOverbar( netName ); for( std::pair terminalPair : net.Terminals ) { @@ -805,7 +812,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets() { SCH_HIERLABEL* label = getHierarchicalLabel( blockPair.first ); - if(label) + if( label ) label->SetText( netName ); } @@ -1236,8 +1243,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef { PART::DEFINITION::PIN csPin = getPartDefinitionPin( *aCadstarPart, aGateID, term.ID ); - pinName = csPin.Label; - pinNum = csPin.Name; + pinName = HandleTextOverbar( csPin.Label ); + pinNum = HandleTextOverbar( csPin.Name ); if( pinNum.IsEmpty() ) { @@ -1667,7 +1674,7 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads return; LIB_PIN* libpin = pinNumToLibPinMap.at( aOldPinNum ); - libpin->SetNumber( aNewPinNum ); + libpin->SetNumber( HandleTextOverbar( aNewPinNum ) ); }; //Older versions of Cadstar used pin numbers @@ -2460,10 +2467,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT int textHeight = KiROUND( (double) getKiCadLength( textCode.Height ) * TXT_HEIGHT_RATIO ); int textWidth = getKiCadLength( textCode.Width ); - // In Cadstar the overbar token is "'" whereas in KiCad it is "~" - wxString escapedText = aKiCadTextItem->GetText(); - escapedText.Replace( wxT( "~" ), wxT( "~~" ) ); - escapedText.Replace( wxT( "'" ), wxT( "~" ) ); + // Ensure we have no Cadstar overbar characters + wxString escapedText = HandleTextOverbar( aKiCadTextItem->GetText() ); aKiCadTextItem->SetText( escapedText ); // The width is zero for all non-cadstar fonts. Using a width equal to 2/3 the height seems diff --git a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp index 23f1ac837c..43622c8a24 100644 --- a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp +++ b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp @@ -1989,7 +1989,7 @@ LIB_TEXT* SCH_EAGLE_PLUGIN::loadSymbolText( std::replace( text.begin(), text.end(), '\n', '_' ); std::replace( text.begin(), text.end(), '\r', '_' ); - libtext->SetText( text.IsEmpty() ? "~~" : text ); + libtext->SetText( text.IsEmpty() ? "~" : text ); loadTextAttributes( libtext.get(), etext ); return libtext.release(); diff --git a/eeschema/sch_text_help.md b/eeschema/sch_text_help.md index c8d4be447e..f077e49b3f 100644 --- a/eeschema/sch_text_help.md +++ b/eeschema/sch_text_help.md @@ -31,12 +31,12 @@ -  
~{overbar}
 
~{CLK}
 
~~ +  
~{overbar}
 
~{CLK} -        
overbar
   
CLK
 
~ +        
overbar
   
CLK -
+  
${variable}