Share Eagle var substitution between board and schematic importers.
Fixes https://gitlab.com/kicad/code/kicad/issues/13541
This commit is contained in:
parent
661eed7fed
commit
ca1fb732c8
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2012-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017 CERN.
|
||||
*
|
||||
* @author Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
|
||||
|
@ -47,6 +47,29 @@ wxString escapeName( const wxString& aNetName )
|
|||
}
|
||||
|
||||
|
||||
bool substituteVariable( wxString* aText )
|
||||
{
|
||||
if ( *aText == wxT( ">NAME" ) ) *aText = wxT( "${REFERENCE}" );
|
||||
else if( *aText == wxT( ">VALUE" ) ) *aText = wxT( "${VALUE}" );
|
||||
else if( *aText == wxT( ">PART" ) ) *aText = wxT( "${REFERENCE}" );
|
||||
else if( *aText == wxT( ">GATE" ) ) *aText = wxT( "${UNIT}" );
|
||||
else if( *aText == wxT( ">MODULE" ) ) *aText = wxT( "${FOOTPRINT_NAME}" );
|
||||
else if( *aText == wxT( ">SHEETNR" ) ) *aText = wxT( "${#}" );
|
||||
else if( *aText == wxT( ">SHEETS" ) ) *aText = wxT( "${##}" );
|
||||
else if( *aText == wxT( ">SHEET" ) ) *aText = wxT( "${#}/${##}" );
|
||||
else if( *aText == wxT( ">SHEETNR_TOTAL" ) ) *aText = wxT( "${#}" );
|
||||
else if( *aText == wxT( ">SHEETS_TOTAL" ) ) *aText = wxT( "${##}" );
|
||||
else if( *aText == wxT( ">SHEET_TOTAL" ) ) *aText = wxT( "${#}/${##}" );
|
||||
else if( *aText == wxT( ">ASSEMBLY_VARIANT" ) ) *aText = wxT( "${ASSEMBLY_VARIANT}" );
|
||||
else if( *aText == wxT( ">DRAWING_NAME" ) ) *aText = wxT( "${TITLE}" );
|
||||
else if( *aText == wxT( ">LAST_DATE_TIME" ) ) *aText = wxT( "${ISSUE_DATE}" );
|
||||
else if( *aText == wxT( ">PLOT_DATE_TIME" ) ) *aText = wxT( "${CURRENT_DATE}" );
|
||||
else return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<> template<>
|
||||
OPTIONAL_XML_ATTRIBUTE<wxString>::OPTIONAL_XML_ATTRIBUTE( wxString aData )
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2012-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017 CERN
|
||||
*
|
||||
* @author Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
|
||||
|
@ -54,6 +54,9 @@ typedef std::map<wxString, std::unique_ptr<EPART>> EPART_MAP;
|
|||
///< Translates Eagle special characters to their counterparts in KiCad.
|
||||
wxString escapeName( const wxString& aNetName );
|
||||
|
||||
///< Translates Eagle special text reference to a KiCad variable reference
|
||||
bool substituteVariable( wxString* aText );
|
||||
|
||||
static inline wxXmlNode* getChildrenNodes( NODE_MAP& aMap, const wxString& aName )
|
||||
{
|
||||
auto it = aMap.find( aName );
|
||||
|
|
|
@ -212,17 +212,11 @@ void SCH_EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers )
|
|||
*/
|
||||
|
||||
if( elayer.name == wxT( "Nets" ) )
|
||||
{
|
||||
m_layerMap[elayer.number] = LAYER_WIRE;
|
||||
}
|
||||
else if( elayer.name == wxT( "Info" ) || elayer.name == wxT( "Guide" ) )
|
||||
{
|
||||
m_layerMap[elayer.number] = LAYER_NOTES;
|
||||
}
|
||||
else if( elayer.name == wxT( "Busses" ) )
|
||||
{
|
||||
m_layerMap[elayer.number] = LAYER_BUS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,24 +235,15 @@ static SYMBOL_ORIENTATION_T kiCadComponentRotation( float eagleDegrees )
|
|||
|
||||
switch( roti )
|
||||
{
|
||||
case 0: return SYM_ORIENT_0;
|
||||
case 90: return SYM_ORIENT_90;
|
||||
case 180: return SYM_ORIENT_180;
|
||||
case 270: return SYM_ORIENT_270;
|
||||
|
||||
default:
|
||||
wxASSERT_MSG( false, wxString::Format( wxT( "Unhandled orientation (%d degrees)" ), roti ) );
|
||||
KI_FALLTHROUGH;
|
||||
|
||||
case 0:
|
||||
return SYM_ORIENT_0;
|
||||
|
||||
case 90:
|
||||
return SYM_ORIENT_90;
|
||||
|
||||
case 180:
|
||||
return SYM_ORIENT_180;
|
||||
|
||||
case 270:
|
||||
return SYM_ORIENT_270;
|
||||
}
|
||||
|
||||
return SYM_ORIENT_0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2588,9 +2573,11 @@ SCH_TEXT* SCH_EAGLE_PLUGIN::loadPlainText( wxXmlNode* aSchText )
|
|||
// Strip the whitespace from both ends of each line.
|
||||
while( tokenizer.HasMoreTokens() )
|
||||
{
|
||||
wxString tmp = tokenizer.GetNextToken().Trim();
|
||||
wxString tmp = tokenizer.GetNextToken().Trim( true ).Trim( false );
|
||||
wxString var = tmp.Upper();
|
||||
|
||||
tmp = tmp.Trim( false );
|
||||
if( substituteVariable( &var ) )
|
||||
tmp = var;
|
||||
|
||||
if( tokenizer.HasMoreTokens() )
|
||||
tmp += wxT( "\n" );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2012-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2012-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -58,15 +58,11 @@ Load() TODO's
|
|||
#include <wx/log.h>
|
||||
#include <wx/wfstream.h>
|
||||
|
||||
#include <eda_pattern_match.h>
|
||||
#include <convert_basic_shapes_to_polygon.h>
|
||||
#include <core/arraydim.h>
|
||||
#include <geometry/geometry_utils.h>
|
||||
#include <string_utils.h>
|
||||
#include <locale_io.h>
|
||||
#include <string_utf8_map.h>
|
||||
#include <trigo.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
#include <progress_reporter.h>
|
||||
#include <project.h>
|
||||
#include <board.h>
|
||||
|
@ -123,21 +119,8 @@ static wxString interpret_text( const wxString& aText )
|
|||
{
|
||||
wxString token = aText.Upper();
|
||||
|
||||
if ( token == wxT( ">NAME" ) ) return wxT( "${REFERENCE}" );
|
||||
else if( token == wxT( ">VALUE" ) ) return wxT( "${VALUE}" );
|
||||
else if( token == wxT( ">PART" ) ) return wxT( "${REFERENCE}" );
|
||||
else if( token == wxT( ">GATE" ) ) return wxT( "${UNIT}" );
|
||||
else if( token == wxT( ">MODULE" ) ) return wxT( "${FOOTPRINT_NAME}" );
|
||||
else if( token == wxT( ">SHEETNR" ) ) return wxT( "${#}" );
|
||||
else if( token == wxT( ">SHEETS" ) ) return wxT( "${##}" );
|
||||
else if( token == wxT( ">SHEET" ) ) return wxT( "${#}/${##}" );
|
||||
else if( token == wxT( ">SHEETNR_TOTAL" ) ) return wxT( "${#}" );
|
||||
else if( token == wxT( ">SHEETS_TOTAL" ) ) return wxT( "${##}" );
|
||||
else if( token == wxT( ">SHEET_TOTAL" ) ) return wxT( "${#}/${##}" );
|
||||
else if( token == wxT( ">ASSEMBLY_VARIANT" ) ) return wxT( "${ASSEMBLY_VARIANT}" );
|
||||
else if( token == wxT( ">DRAWING_NAME" ) ) return wxT( "${TITLE}" );
|
||||
else if( token == wxT( ">LAST_DATE_TIME" ) ) return wxT( "${ISSUE_DATE}" );
|
||||
else if( token == wxT( ">PLOT_DATE_TIME" ) ) return wxT( "${CURRENT_DATE}" );
|
||||
if( substituteVariable( &token ) )
|
||||
return token;
|
||||
|
||||
wxString text;
|
||||
bool sectionOpen = false;
|
||||
|
|
Loading…
Reference in New Issue