Fix issues with new overbar syntax
- Update sch text help (~~ no longer gets converted to single ~) - Update Eagle importer to correctly handle new overbar syntax - Update CADSTAR importer to correctly handle new overbar syntax
This commit is contained in:
parent
130958e48e
commit
0aa37d1173
|
@ -31,6 +31,7 @@
|
||||||
#include <eda_item.h>
|
#include <eda_item.h>
|
||||||
#include <eda_text.h>
|
#include <eda_text.h>
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
|
#include <string_utils.h>
|
||||||
#include <trigo.h>
|
#include <trigo.h>
|
||||||
|
|
||||||
// Ratio derived from CADSTAR default font. See doxygen comment in cadstar_archive_parser.h
|
// Ratio derived from CADSTAR default font. See doxygen comment in cadstar_archive_parser.h
|
||||||
|
@ -2546,6 +2547,16 @@ std::vector<CADSTAR_ARCHIVE_PARSER::CUTOUT> 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 )
|
void CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment( EDA_TEXT* aKiCadTextItem )
|
||||||
{
|
{
|
||||||
if( !aKiCadTextItem->GetText().IsEmpty() )
|
if( !aKiCadTextItem->GetText().IsEmpty() )
|
||||||
|
|
|
@ -1368,6 +1368,13 @@ public:
|
||||||
static std::vector<CUTOUT> ParseAllChildCutouts(
|
static std::vector<CUTOUT> ParseAllChildCutouts(
|
||||||
XNODE* aNode, PARSER_CONTEXT* aContext, bool aTestAllChildNodes = false );
|
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
|
* 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.
|
* provided text element has been initialised with a position and orientation.
|
||||||
|
|
|
@ -41,10 +41,9 @@ wxString escapeName( const wxString& aNetName )
|
||||||
{
|
{
|
||||||
wxString ret( aNetName );
|
wxString ret( aNetName );
|
||||||
|
|
||||||
ret.Replace( "~", "~~" );
|
|
||||||
ret.Replace( "!", "~" );
|
ret.Replace( "!", "~" );
|
||||||
|
|
||||||
return ret;
|
return ConvertToNewOverbarNotation( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -680,7 +680,10 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadBusses()
|
||||||
m_busesMap.insert( { bus.ID, kiBusAlias } );
|
m_busesMap.insert( { bus.ID, kiBusAlias } );
|
||||||
|
|
||||||
SCH_LABEL* label = new SCH_LABEL();
|
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 );
|
label->SetVisible( true );
|
||||||
screen->Append( label );
|
screen->Append( label );
|
||||||
|
|
||||||
|
@ -730,6 +733,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadBusses()
|
||||||
bus.BusLabel.Alignment,
|
bus.BusLabel.Alignment,
|
||||||
bus.BusLabel.Justification );
|
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
|
// 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)
|
// (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() )
|
if( netName.IsEmpty() )
|
||||||
netName = wxString::Format( "$%ld", net.SignalNum );
|
netName = wxString::Format( "$%ld", net.SignalNum );
|
||||||
|
|
||||||
|
netName = HandleTextOverbar( netName );
|
||||||
|
|
||||||
for( std::pair<NETELEMENT_ID, NET_SCH::SYM_TERM> terminalPair : net.Terminals )
|
for( std::pair<NETELEMENT_ID, NET_SCH::SYM_TERM> terminalPair : net.Terminals )
|
||||||
{
|
{
|
||||||
|
@ -805,7 +812,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets()
|
||||||
{
|
{
|
||||||
SCH_HIERLABEL* label = getHierarchicalLabel( blockPair.first );
|
SCH_HIERLABEL* label = getHierarchicalLabel( blockPair.first );
|
||||||
|
|
||||||
if(label)
|
if( label )
|
||||||
label->SetText( netName );
|
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 );
|
PART::DEFINITION::PIN csPin = getPartDefinitionPin( *aCadstarPart, aGateID, term.ID );
|
||||||
|
|
||||||
pinName = csPin.Label;
|
pinName = HandleTextOverbar( csPin.Label );
|
||||||
pinNum = csPin.Name;
|
pinNum = HandleTextOverbar( csPin.Name );
|
||||||
|
|
||||||
if( pinNum.IsEmpty() )
|
if( pinNum.IsEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -1667,7 +1674,7 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LIB_PIN* libpin = pinNumToLibPinMap.at( aOldPinNum );
|
LIB_PIN* libpin = pinNumToLibPinMap.at( aOldPinNum );
|
||||||
libpin->SetNumber( aNewPinNum );
|
libpin->SetNumber( HandleTextOverbar( aNewPinNum ) );
|
||||||
};
|
};
|
||||||
|
|
||||||
//Older versions of Cadstar used pin numbers
|
//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 textHeight = KiROUND( (double) getKiCadLength( textCode.Height ) * TXT_HEIGHT_RATIO );
|
||||||
int textWidth = getKiCadLength( textCode.Width );
|
int textWidth = getKiCadLength( textCode.Width );
|
||||||
|
|
||||||
// In Cadstar the overbar token is "'" whereas in KiCad it is "~"
|
// Ensure we have no Cadstar overbar characters
|
||||||
wxString escapedText = aKiCadTextItem->GetText();
|
wxString escapedText = HandleTextOverbar( aKiCadTextItem->GetText() );
|
||||||
escapedText.Replace( wxT( "~" ), wxT( "~~" ) );
|
|
||||||
escapedText.Replace( wxT( "'" ), wxT( "~" ) );
|
|
||||||
aKiCadTextItem->SetText( escapedText );
|
aKiCadTextItem->SetText( escapedText );
|
||||||
|
|
||||||
// The width is zero for all non-cadstar fonts. Using a width equal to 2/3 the height seems
|
// The width is zero for all non-cadstar fonts. Using a width equal to 2/3 the height seems
|
||||||
|
|
|
@ -1989,7 +1989,7 @@ LIB_TEXT* SCH_EAGLE_PLUGIN::loadSymbolText(
|
||||||
std::replace( text.begin(), text.end(), '\n', '_' );
|
std::replace( text.begin(), text.end(), '\n', '_' );
|
||||||
std::replace( text.begin(), text.end(), '\r', '_' );
|
std::replace( text.begin(), text.end(), '\r', '_' );
|
||||||
|
|
||||||
libtext->SetText( text.IsEmpty() ? "~~" : text );
|
libtext->SetText( text.IsEmpty() ? "~" : text );
|
||||||
loadTextAttributes( libtext.get(), etext );
|
loadTextAttributes( libtext.get(), etext );
|
||||||
|
|
||||||
return libtext.release();
|
return libtext.release();
|
||||||
|
|
|
@ -31,12 +31,12 @@
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td> <br><samp>~{overbar}</samp><br> <br><samp>~{CLK}</samp><br> <br><samp>~~</samp> </td>
|
<td> <br><samp>~{overbar}</samp><br> <br><samp>~{CLK}</samp></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td> <samp><u> </u></samp><br> <samp>overbar</samp><br> <samp><u> </u></samp><br> <samp>CLK</samp><br> <samp> </samp><br> <samp>~</samp> </td>
|
<td> <samp><u> </u></samp><br> <samp>overbar</samp><br> <samp><u> </u></samp><br> <samp>CLK</samp></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td> <br><samp>${variable}</samp></td>
|
<td> <br><samp>${variable}</samp></td>
|
||||||
|
|
Loading…
Reference in New Issue