2017-04-07 11:40:34 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2021-02-15 21:44:58 +00:00
|
|
|
* Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-04-07 11:40:34 +00:00
|
|
|
* Copyright (C) 2017 CERN.
|
2021-02-15 21:44:58 +00:00
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @author Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2020-10-03 20:48:58 +00:00
|
|
|
#include <plugins/eagle/eagle_parser.h>
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2020-10-24 12:44:03 +00:00
|
|
|
#include <richio.h>
|
2021-06-01 05:17:57 +00:00
|
|
|
#include <wx/log.h>
|
2020-10-24 12:44:03 +00:00
|
|
|
|
2017-07-17 12:09:01 +00:00
|
|
|
#include <functional>
|
2017-10-17 08:18:54 +00:00
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
constexpr auto DEFAULT_ALIGNMENT = ETEXT::BOTTOM_LEFT;
|
|
|
|
|
|
|
|
|
2018-02-16 23:01:43 +00:00
|
|
|
wxString escapeName( const wxString& aNetName )
|
|
|
|
{
|
|
|
|
wxString ret( aNetName );
|
|
|
|
|
|
|
|
ret.Replace( "!", "~" );
|
|
|
|
|
2021-09-01 18:24:42 +00:00
|
|
|
return ConvertToNewOverbarNotation( ret );
|
2018-02-16 23:01:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
template<> template<>
|
|
|
|
OPTIONAL_XML_ATTRIBUTE<wxString>::OPTIONAL_XML_ATTRIBUTE( wxString aData )
|
|
|
|
{
|
|
|
|
m_isAvailable = !aData.IsEmpty();
|
|
|
|
|
|
|
|
if( m_isAvailable )
|
|
|
|
Set( aData );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-23 13:37:24 +00:00
|
|
|
ECOORD::ECOORD( const wxString& aValue, enum ECOORD::EAGLE_UNIT aUnit )
|
2017-10-17 08:18:54 +00:00
|
|
|
{
|
2021-02-15 21:44:58 +00:00
|
|
|
// This array is used to adjust the fraction part value basing on the number of digits
|
|
|
|
// in the fraction.
|
2017-10-17 08:18:54 +00:00
|
|
|
constexpr int DIVIDERS[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 };
|
|
|
|
constexpr unsigned int DIVIDERS_MAX_IDX = sizeof( DIVIDERS ) / sizeof( DIVIDERS[0] ) - 1;
|
|
|
|
|
|
|
|
int integer, fraction, pre_fraction, post_fraction;
|
|
|
|
|
2021-02-15 21:44:58 +00:00
|
|
|
// The following check is needed to handle correctly negative fractions where the integer
|
|
|
|
// part == 0.
|
2017-10-17 08:18:54 +00:00
|
|
|
bool negative = ( aValue[0] == '-' );
|
|
|
|
|
2021-02-15 21:44:58 +00:00
|
|
|
// %n is used to find out how many digits contains the fraction part, e.g. 0.001 contains 3
|
|
|
|
// digits.
|
|
|
|
int ret = sscanf( aValue.c_str(), "%d.%n%d%n", &integer, &pre_fraction, &fraction,
|
|
|
|
&post_fraction );
|
2017-10-17 08:18:54 +00:00
|
|
|
|
|
|
|
if( ret == 0 )
|
|
|
|
throw XML_PARSER_ERROR( "Invalid coordinate" );
|
|
|
|
|
|
|
|
// process the integer part
|
2018-03-13 12:54:08 +00:00
|
|
|
value = ConvertToNm( integer, aUnit );
|
2017-10-17 08:18:54 +00:00
|
|
|
|
|
|
|
// process the fraction part
|
|
|
|
if( ret == 2 )
|
|
|
|
{
|
|
|
|
int digits = post_fraction - pre_fraction;
|
|
|
|
|
2021-02-15 21:44:58 +00:00
|
|
|
// adjust the number of digits if necessary as we cannot handle anything smaller than
|
|
|
|
// nanometers (rounding).
|
2017-10-17 08:18:54 +00:00
|
|
|
if( (unsigned) digits > DIVIDERS_MAX_IDX )
|
|
|
|
{
|
|
|
|
int diff = digits - DIVIDERS_MAX_IDX;
|
|
|
|
digits = DIVIDERS_MAX_IDX;
|
|
|
|
fraction /= DIVIDERS[diff];
|
|
|
|
}
|
|
|
|
|
2018-03-13 12:54:08 +00:00
|
|
|
int frac_value = ConvertToNm( fraction, aUnit ) / DIVIDERS[digits];
|
2017-10-17 08:18:54 +00:00
|
|
|
|
|
|
|
// keep the sign in mind
|
|
|
|
value = negative ? value - frac_value : value + frac_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-13 12:54:08 +00:00
|
|
|
long long int ECOORD::ConvertToNm( int aValue, enum EAGLE_UNIT aUnit )
|
2017-10-17 08:18:54 +00:00
|
|
|
{
|
|
|
|
long long int ret;
|
|
|
|
|
|
|
|
switch( aUnit )
|
|
|
|
{
|
2017-10-23 13:37:24 +00:00
|
|
|
default:
|
2018-03-13 12:54:08 +00:00
|
|
|
case EU_NM: ret = aValue; break;
|
|
|
|
case EU_MM: ret = (long long) aValue * 1000000; break;
|
|
|
|
case EU_INCH: ret = (long long) aValue * 25400000; break;
|
|
|
|
case EU_MIL: ret = (long long) aValue * 25400; break;
|
2017-10-17 08:18:54 +00:00
|
|
|
}
|
|
|
|
|
2019-05-27 03:12:27 +00:00
|
|
|
if( ( ret > 0 ) != ( aValue > 0 ) )
|
|
|
|
wxLogError( _( "Invalid size %lld: too large" ), aValue );
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
// Template specializations below parse wxString to the used types:
|
2017-12-14 09:37:32 +00:00
|
|
|
// - wxString (preferred)
|
2017-04-07 11:40:34 +00:00
|
|
|
// - string
|
|
|
|
// - double
|
|
|
|
// - int
|
|
|
|
// - bool
|
|
|
|
// - EROT
|
2017-10-17 08:18:54 +00:00
|
|
|
// - ECOORD
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
template <>
|
|
|
|
wxString Convert<wxString>( const wxString& aValue )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
2017-12-14 09:37:32 +00:00
|
|
|
return aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
std::string Convert<std::string>( const wxString& aValue )
|
|
|
|
{
|
|
|
|
return std::string( aValue.ToUTF8() );
|
2017-04-07 11:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <>
|
2017-09-02 01:04:25 +00:00
|
|
|
double Convert<double>( const wxString& aValue )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
|
|
|
double value;
|
|
|
|
|
2020-07-12 13:26:36 +00:00
|
|
|
if( aValue.ToCDouble( &value ) )
|
2017-04-07 11:40:34 +00:00
|
|
|
return value;
|
|
|
|
else
|
|
|
|
throw XML_PARSER_ERROR( "Conversion to double failed. Original value: '" +
|
|
|
|
aValue.ToStdString() + "'." );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <>
|
2017-09-02 01:04:25 +00:00
|
|
|
int Convert<int>( const wxString& aValue )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
|
|
|
if( aValue.IsEmpty() )
|
|
|
|
throw XML_PARSER_ERROR( "Conversion to int failed. Original value is empty." );
|
|
|
|
|
|
|
|
return wxAtoi( aValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <>
|
2017-09-02 01:04:25 +00:00
|
|
|
bool Convert<bool>( const wxString& aValue )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
|
|
|
if( aValue != "yes" && aValue != "no" )
|
|
|
|
throw XML_PARSER_ERROR( "Conversion to bool failed. Original value, '" +
|
|
|
|
aValue.ToStdString() +
|
|
|
|
"', is neither 'yes' nor 'no'." );
|
|
|
|
|
|
|
|
return aValue == "yes";
|
|
|
|
}
|
|
|
|
|
2017-05-04 13:37:01 +00:00
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
/// parse an Eagle XML "rot" field. Unfortunately the DTD seems not to explain
|
|
|
|
/// this format very well. [S][M]R<degrees>. Examples: "R90", "MR180", "SR180"
|
|
|
|
template<>
|
2017-09-02 01:04:25 +00:00
|
|
|
EROT Convert<EROT>( const wxString& aRot )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
|
|
|
EROT value;
|
|
|
|
|
|
|
|
value.spin = aRot.find( 'S' ) != aRot.npos;
|
|
|
|
value.mirror = aRot.find( 'M' ) != aRot.npos;
|
|
|
|
value.degrees = strtod( aRot.c_str()
|
|
|
|
+ 1 // skip leading 'R'
|
|
|
|
+ int( value.spin ) // skip optional leading 'S'
|
|
|
|
+ int( value.mirror ), // skip optional leading 'M'
|
2021-07-15 19:26:35 +00:00
|
|
|
nullptr );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
|
|
|
|
template<>
|
|
|
|
ECOORD Convert<ECOORD>( const wxString& aCoord )
|
|
|
|
{
|
|
|
|
// Eagle uses millimeters as the default unit
|
2018-03-13 12:54:08 +00:00
|
|
|
return ECOORD( aCoord, ECOORD::EAGLE_UNIT::EU_MM );
|
2017-10-17 08:18:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
/**
|
2021-02-15 21:44:58 +00:00
|
|
|
* Parse \a aAttribute of the XML node \a aNode.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @param aNode is the node whose attribute will be parsed.
|
|
|
|
* @param aAttribute is the attribute that will be parsed.
|
|
|
|
* @throw XML_PARSER_ERROR - exception thrown if the required attribute is missing
|
|
|
|
* @return T - the attributed parsed as the specified type.
|
|
|
|
*/
|
|
|
|
template<typename T>
|
2017-12-14 09:37:32 +00:00
|
|
|
T parseRequiredAttribute( wxXmlNode* aNode, const wxString& aAttribute )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
|
|
|
wxString value;
|
|
|
|
|
|
|
|
if( aNode->GetAttribute( aAttribute, &value ) )
|
|
|
|
return Convert<T>( value );
|
|
|
|
else
|
|
|
|
throw XML_PARSER_ERROR( "The required attribute " + aAttribute + " is missing." );
|
|
|
|
}
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
/**
|
2021-02-15 21:44:58 +00:00
|
|
|
* Parse option \a aAttribute of the XML node \a aNode.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @param aNode is the node whose attribute will be parsed.
|
|
|
|
* @param aAttribute is the attribute that will be parsed.
|
|
|
|
* @return OPTIONAL_XML_ATTRIBUTE<T> - an optional XML attribute, parsed as the specified type if
|
2021-02-15 21:44:58 +00:00
|
|
|
* found.
|
2017-04-07 11:40:34 +00:00
|
|
|
*/
|
|
|
|
template<typename T>
|
2017-12-14 09:37:32 +00:00
|
|
|
OPTIONAL_XML_ATTRIBUTE<T> parseOptionalAttribute( wxXmlNode* aNode, const wxString& aAttribute )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
|
|
|
return OPTIONAL_XML_ATTRIBUTE<T>( aNode->GetAttribute( aAttribute ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-03 10:30:23 +00:00
|
|
|
NODE_MAP MapChildren( wxXmlNode* aCurrentNode )
|
2017-06-26 07:51:51 +00:00
|
|
|
{
|
|
|
|
// Map node_name -> node_pointer
|
|
|
|
NODE_MAP nodesMap;
|
|
|
|
|
|
|
|
// Loop through all children mapping them in nodesMap
|
2017-10-03 10:30:23 +00:00
|
|
|
if( aCurrentNode )
|
|
|
|
aCurrentNode = aCurrentNode->GetChildren();
|
2017-06-26 07:51:51 +00:00
|
|
|
|
2017-10-03 10:30:23 +00:00
|
|
|
while( aCurrentNode )
|
2017-06-26 07:51:51 +00:00
|
|
|
{
|
|
|
|
// Create a new pair in the map
|
|
|
|
// key: current node name
|
|
|
|
// value: current node pointer
|
2017-12-14 09:37:32 +00:00
|
|
|
nodesMap[aCurrentNode->GetName()] = aCurrentNode;
|
2017-10-03 10:23:52 +00:00
|
|
|
|
|
|
|
// Get next child
|
|
|
|
aCurrentNode = aCurrentNode->GetNext();
|
|
|
|
}
|
|
|
|
|
2017-10-03 10:30:23 +00:00
|
|
|
return nodesMap;
|
2017-06-26 07:51:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I ConvertArcCenter( const VECTOR2I& aStart, const VECTOR2I& aEnd, double aAngle )
|
2017-06-26 07:51:51 +00:00
|
|
|
{
|
|
|
|
// Eagle give us start and end.
|
|
|
|
// S_ARC wants start to give the center, and end to give the start.
|
|
|
|
double dx = aEnd.x - aStart.x, dy = aEnd.y - aStart.y;
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I mid = ( aStart + aEnd ) / 2;
|
2017-06-26 07:51:51 +00:00
|
|
|
|
|
|
|
double dlen = sqrt( dx*dx + dy*dy );
|
2019-05-27 03:12:27 +00:00
|
|
|
|
|
|
|
if( !std::isnormal( dlen ) || !std::isnormal( aAngle ) )
|
|
|
|
{
|
2021-09-20 11:36:57 +00:00
|
|
|
THROW_IO_ERROR( wxString::Format( _( "Invalid Arc with radius %f and angle %f" ),
|
|
|
|
dlen,
|
|
|
|
aAngle ) );
|
2019-05-27 03:12:27 +00:00
|
|
|
}
|
|
|
|
|
2017-06-26 07:51:51 +00:00
|
|
|
double dist = dlen / ( 2 * tan( DEG2RAD( aAngle ) / 2 ) );
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I center(
|
2017-06-26 07:51:51 +00:00
|
|
|
mid.x + dist * ( dy / dlen ),
|
|
|
|
mid.y - dist * ( dx / dlen )
|
|
|
|
);
|
|
|
|
|
|
|
|
return center;
|
|
|
|
}
|
|
|
|
|
2017-10-03 10:30:23 +00:00
|
|
|
|
|
|
|
static int parseAlignment( const wxString& aAlignment )
|
2017-07-16 16:12:05 +00:00
|
|
|
{
|
|
|
|
// (bottom-left | bottom-center | bottom-right | center-left |
|
2017-10-03 10:23:52 +00:00
|
|
|
// center | center-right | top-left | top-center | top-right)
|
2017-10-03 10:30:23 +00:00
|
|
|
if( aAlignment == "center" )
|
2017-07-16 16:12:05 +00:00
|
|
|
return ETEXT::CENTER;
|
2017-10-03 10:30:23 +00:00
|
|
|
else if( aAlignment == "center-right" )
|
2017-10-03 10:23:52 +00:00
|
|
|
return ETEXT::CENTER_RIGHT;
|
2017-10-03 10:30:23 +00:00
|
|
|
else if( aAlignment == "top-left" )
|
2017-10-03 10:23:52 +00:00
|
|
|
return ETEXT::TOP_LEFT;
|
2017-10-03 10:30:23 +00:00
|
|
|
else if( aAlignment == "top-center" )
|
2017-10-03 10:23:52 +00:00
|
|
|
return ETEXT::TOP_CENTER;
|
2017-10-03 10:30:23 +00:00
|
|
|
else if( aAlignment == "top-right" )
|
2017-10-03 10:23:52 +00:00
|
|
|
return ETEXT::TOP_RIGHT;
|
2017-10-03 10:30:23 +00:00
|
|
|
else if( aAlignment == "bottom-left" )
|
2017-10-03 10:23:52 +00:00
|
|
|
return ETEXT::BOTTOM_LEFT;
|
2017-10-03 10:30:23 +00:00
|
|
|
else if( aAlignment == "bottom-center" )
|
2017-10-03 10:23:52 +00:00
|
|
|
return ETEXT::BOTTOM_CENTER;
|
2017-10-03 10:30:23 +00:00
|
|
|
else if( aAlignment == "bottom-right" )
|
2017-10-03 10:23:52 +00:00
|
|
|
return ETEXT::BOTTOM_RIGHT;
|
2017-10-03 10:30:23 +00:00
|
|
|
else if( aAlignment == "center-left" )
|
2017-10-03 10:23:52 +00:00
|
|
|
return ETEXT::CENTER_LEFT;
|
2017-07-16 16:12:05 +00:00
|
|
|
|
2017-07-17 10:17:23 +00:00
|
|
|
return DEFAULT_ALIGNMENT;
|
2017-07-16 16:12:05 +00:00
|
|
|
}
|
|
|
|
|
2017-10-03 10:23:52 +00:00
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
EWIRE::EWIRE( wxXmlNode* aWire )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT wire EMPTY>
|
|
|
|
<!ATTLIST wire
|
|
|
|
x1 %Coord; #REQUIRED
|
|
|
|
y1 %Coord; #REQUIRED
|
|
|
|
x2 %Coord; #REQUIRED
|
|
|
|
y2 %Coord; #REQUIRED
|
|
|
|
width %Dimension; #REQUIRED
|
|
|
|
layer %Layer; #REQUIRED
|
|
|
|
extent %Extent; #IMPLIED -- only applicable for airwires --
|
|
|
|
style %WireStyle; "continuous"
|
|
|
|
curve %WireCurve; "0"
|
|
|
|
cap %WireCap; "round" -- only applicable if 'curve' is not zero --
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
x1 = parseRequiredAttribute<ECOORD>( aWire, "x1" );
|
|
|
|
y1 = parseRequiredAttribute<ECOORD>( aWire, "y1" );
|
|
|
|
x2 = parseRequiredAttribute<ECOORD>( aWire, "x2" );
|
|
|
|
y2 = parseRequiredAttribute<ECOORD>( aWire, "y2" );
|
|
|
|
width = parseRequiredAttribute<ECOORD>( aWire, "width" );
|
2017-04-07 11:40:34 +00:00
|
|
|
layer = parseRequiredAttribute<int>( aWire, "layer" );
|
|
|
|
curve = parseOptionalAttribute<double>( aWire, "curve" );
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
opt_wxString s = parseOptionalAttribute<wxString>( aWire, "style" );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
if( s == "continuous" )
|
|
|
|
style = EWIRE::CONTINUOUS;
|
|
|
|
else if( s == "longdash" )
|
|
|
|
style = EWIRE::LONGDASH;
|
|
|
|
else if( s == "shortdash" )
|
|
|
|
style = EWIRE::SHORTDASH;
|
|
|
|
else if( s == "dashdot" )
|
|
|
|
style = EWIRE::DASHDOT;
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
s = parseOptionalAttribute<wxString>( aWire, "cap" );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
if( s == "round" )
|
|
|
|
cap = EWIRE::ROUND;
|
|
|
|
else if( s == "flat" )
|
|
|
|
cap = EWIRE::FLAT;
|
|
|
|
}
|
|
|
|
|
2017-06-19 13:43:55 +00:00
|
|
|
|
|
|
|
EJUNCTION::EJUNCTION( wxXmlNode* aJunction )
|
2017-06-18 11:31:11 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT junction EMPTY>
|
|
|
|
<!ATTLIST junction
|
|
|
|
x %Coord; #REQUIRED
|
|
|
|
y %Coord; #REQUIRED
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
x = parseRequiredAttribute<ECOORD>( aJunction, "x" );
|
|
|
|
y = parseRequiredAttribute<ECOORD>( aJunction, "y" );
|
2017-06-18 11:31:11 +00:00
|
|
|
}
|
|
|
|
|
2017-06-19 13:43:55 +00:00
|
|
|
|
2017-06-19 13:43:25 +00:00
|
|
|
ELABEL::ELABEL( wxXmlNode* aLabel, const wxString& aNetName )
|
2017-06-18 11:31:11 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT label EMPTY>
|
|
|
|
<!ATTLIST label
|
|
|
|
x %Coord; #REQUIRED
|
|
|
|
y %Coord; #REQUIRED
|
|
|
|
size %Dimension; #REQUIRED
|
|
|
|
layer %Layer; #REQUIRED
|
|
|
|
font %TextFont; "proportional"
|
|
|
|
ratio %Int; "8"
|
|
|
|
rot %Rotation; "R0"
|
|
|
|
xref %Bool; "no"
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
x = parseRequiredAttribute<ECOORD>( aLabel, "x" );
|
|
|
|
y = parseRequiredAttribute<ECOORD>( aLabel, "y" );
|
|
|
|
size = parseRequiredAttribute<ECOORD>( aLabel, "size" );
|
2017-06-18 11:31:11 +00:00
|
|
|
layer = parseRequiredAttribute<int>( aLabel, "layer" );
|
|
|
|
rot = parseOptionalAttribute<EROT>( aLabel, "rot" );
|
2017-12-14 09:37:32 +00:00
|
|
|
xref = parseOptionalAttribute<wxString>( aLabel, "xref" );
|
2017-06-18 11:31:11 +00:00
|
|
|
netname = aNetName;
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
EVIA::EVIA( wxXmlNode* aVia )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT via EMPTY>
|
|
|
|
<!ATTLIST via
|
|
|
|
x %Coord; #REQUIRED
|
|
|
|
y %Coord; #REQUIRED
|
|
|
|
extent %Extent; #REQUIRED
|
|
|
|
drill %Dimension; #REQUIRED
|
|
|
|
diameter %Dimension; "0"
|
|
|
|
shape %ViaShape; "round"
|
|
|
|
alwaysstop %Bool; "no"
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
x = parseRequiredAttribute<ECOORD>( aVia, "x" );
|
|
|
|
y = parseRequiredAttribute<ECOORD>( aVia, "y" );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
wxString ext = parseRequiredAttribute<wxString>( aVia, "extent" );
|
2017-04-07 11:40:34 +00:00
|
|
|
sscanf( ext.c_str(), "%d-%d", &layer_front_most, &layer_back_most );
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
drill = parseRequiredAttribute<ECOORD>( aVia, "drill" );
|
|
|
|
diam = parseOptionalAttribute<ECOORD>( aVia, "diameter" );
|
2017-12-14 09:37:32 +00:00
|
|
|
shape = parseOptionalAttribute<wxString>( aVia, "shape" );
|
2017-04-07 11:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ECIRCLE::ECIRCLE( wxXmlNode* aCircle )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT circle EMPTY>
|
|
|
|
<!ATTLIST circle
|
|
|
|
x %Coord; #REQUIRED
|
|
|
|
y %Coord; #REQUIRED
|
|
|
|
radius %Coord; #REQUIRED
|
|
|
|
width %Dimension; #REQUIRED
|
|
|
|
layer %Layer; #REQUIRED
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
x = parseRequiredAttribute<ECOORD>( aCircle, "x" );
|
|
|
|
y = parseRequiredAttribute<ECOORD>( aCircle, "y" );
|
|
|
|
radius = parseRequiredAttribute<ECOORD>( aCircle, "radius" );
|
|
|
|
width = parseRequiredAttribute<ECOORD>( aCircle, "width" );
|
2017-04-07 11:40:34 +00:00
|
|
|
layer = parseRequiredAttribute<int>( aCircle, "layer" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ERECT::ERECT( wxXmlNode* aRect )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT rectangle EMPTY>
|
|
|
|
<!ATTLIST rectangle
|
|
|
|
x1 %Coord; #REQUIRED
|
|
|
|
y1 %Coord; #REQUIRED
|
|
|
|
x2 %Coord; #REQUIRED
|
|
|
|
y2 %Coord; #REQUIRED
|
|
|
|
layer %Layer; #REQUIRED
|
|
|
|
rot %Rotation; "R0"
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
x1 = parseRequiredAttribute<ECOORD>( aRect, "x1" );
|
|
|
|
y1 = parseRequiredAttribute<ECOORD>( aRect, "y1" );
|
|
|
|
x2 = parseRequiredAttribute<ECOORD>( aRect, "x2" );
|
|
|
|
y2 = parseRequiredAttribute<ECOORD>( aRect, "y2" );
|
2017-04-07 11:40:34 +00:00
|
|
|
layer = parseRequiredAttribute<int>( aRect, "layer" );
|
|
|
|
rot = parseOptionalAttribute<EROT>( aRect, "rot" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EATTR::EATTR( wxXmlNode* aTree )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT attribute EMPTY>
|
|
|
|
<!ATTLIST attribute
|
|
|
|
name %String; #REQUIRED
|
|
|
|
value %String; #IMPLIED
|
|
|
|
x %Coord; #IMPLIED
|
|
|
|
y %Coord; #IMPLIED
|
|
|
|
size %Dimension; #IMPLIED
|
|
|
|
layer %Layer; #IMPLIED
|
|
|
|
font %TextFont; #IMPLIED
|
|
|
|
ratio %Int; #IMPLIED
|
|
|
|
rot %Rotation; "R0"
|
|
|
|
display %AttributeDisplay; "value" -- only in <element> or <instance> context --
|
|
|
|
constant %Bool; "no" -- only in <device> context --
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
name = parseRequiredAttribute<wxString>( aTree, "name" );
|
|
|
|
value = parseOptionalAttribute<wxString>( aTree, "value" );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
x = parseOptionalAttribute<ECOORD>( aTree, "x" );
|
|
|
|
y = parseOptionalAttribute<ECOORD>( aTree, "y" );
|
|
|
|
size = parseOptionalAttribute<ECOORD>( aTree, "size" );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
layer = parseOptionalAttribute<int>( aTree, "layer" );
|
|
|
|
ratio = parseOptionalAttribute<double>( aTree, "ratio" );
|
|
|
|
rot = parseOptionalAttribute<EROT>( aTree, "rot" );
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
opt_wxString stemp = parseOptionalAttribute<wxString>( aTree, "display" );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
// (off | value | name | both)
|
|
|
|
if( stemp == "off" )
|
|
|
|
display = EATTR::Off;
|
|
|
|
else if( stemp == "name" )
|
|
|
|
display = EATTR::NAME;
|
|
|
|
else if( stemp == "both" )
|
|
|
|
display = EATTR::BOTH;
|
2018-05-11 13:44:36 +00:00
|
|
|
else // "value" is the default
|
|
|
|
display = EATTR::VALUE;
|
2017-07-16 16:12:05 +00:00
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
stemp = parseOptionalAttribute<wxString>( aTree, "align" );
|
2017-07-16 16:12:05 +00:00
|
|
|
|
2017-07-17 10:17:23 +00:00
|
|
|
align = stemp ? parseAlignment( *stemp ) : DEFAULT_ALIGNMENT;
|
2017-04-07 11:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EDIMENSION::EDIMENSION( wxXmlNode* aDimension )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT dimension EMPTY>
|
|
|
|
<!ATTLIST dimension
|
|
|
|
x1 %Coord; #REQUIRED
|
|
|
|
y1 %Coord; #REQUIRED
|
|
|
|
x2 %Coord; #REQUIRED
|
|
|
|
y2 %Coord; #REQUIRED
|
|
|
|
x3 %Coord; #REQUIRED
|
|
|
|
y3 %Coord; #REQUIRED
|
2022-04-12 12:21:27 +00:00
|
|
|
textsize %Coord;
|
2017-04-07 11:40:34 +00:00
|
|
|
layer %Layer; #REQUIRED
|
|
|
|
dtype %DimensionType; "parallel"
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
2022-04-12 12:21:27 +00:00
|
|
|
x1 = parseRequiredAttribute<ECOORD>( aDimension, wxT( "x1" ) );
|
|
|
|
y1 = parseRequiredAttribute<ECOORD>( aDimension, wxT( "y1" ) );
|
|
|
|
x2 = parseRequiredAttribute<ECOORD>( aDimension, wxT( "x2" ) );
|
|
|
|
y2 = parseRequiredAttribute<ECOORD>( aDimension, wxT( "y2" ) );
|
|
|
|
x3 = parseRequiredAttribute<ECOORD>( aDimension, wxT( "x3" ) );
|
|
|
|
y3 = parseRequiredAttribute<ECOORD>( aDimension, wxT( "y3" ) );
|
|
|
|
textsize = parseOptionalAttribute<ECOORD>( aDimension, wxT( "textsize" ) );
|
|
|
|
layer = parseRequiredAttribute<int>( aDimension, wxT( "layer" ) );
|
|
|
|
dimensionType = parseOptionalAttribute<wxString>( aDimension, wxT( "dtype" ) );
|
2017-04-07 11:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ETEXT::ETEXT( wxXmlNode* aText )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT text (#PCDATA)>
|
|
|
|
<!ATTLIST text
|
|
|
|
x %Coord; #REQUIRED
|
|
|
|
y %Coord; #REQUIRED
|
|
|
|
size %Dimension; #REQUIRED
|
|
|
|
layer %Layer; #REQUIRED
|
|
|
|
font %TextFont; "proportional"
|
|
|
|
ratio %Int; "8"
|
|
|
|
rot %Rotation; "R0"
|
|
|
|
align %Align; "bottom-left"
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
|
|
|
text = aText->GetNodeContent();
|
2017-10-17 08:18:54 +00:00
|
|
|
x = parseRequiredAttribute<ECOORD>( aText, "x" );
|
|
|
|
y = parseRequiredAttribute<ECOORD>( aText, "y" );
|
|
|
|
size = parseRequiredAttribute<ECOORD>( aText, "size" );
|
2017-04-07 11:40:34 +00:00
|
|
|
layer = parseRequiredAttribute<int>( aText, "layer" );
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
font = parseOptionalAttribute<wxString>( aText, "font" );
|
2017-04-07 11:40:34 +00:00
|
|
|
ratio = parseOptionalAttribute<double>( aText, "ratio" );
|
|
|
|
rot = parseOptionalAttribute<EROT>( aText, "rot" );
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
opt_wxString stemp = parseOptionalAttribute<wxString>( aText, "align" );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2017-07-17 10:17:23 +00:00
|
|
|
align = stemp ? parseAlignment( *stemp ) : DEFAULT_ALIGNMENT;
|
2017-04-07 11:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-12 14:06:54 +00:00
|
|
|
wxSize ETEXT::ConvertSize() const
|
|
|
|
{
|
|
|
|
wxSize textsize;
|
|
|
|
|
|
|
|
if( font )
|
|
|
|
{
|
|
|
|
const wxString& fontName = font.CGet();
|
|
|
|
|
|
|
|
if( fontName == "vector" )
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
textsize = wxSize( size.ToSchUnits(), size.ToSchUnits() );
|
2017-09-12 14:06:54 +00:00
|
|
|
}
|
|
|
|
else if( fontName == "fixed" )
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
textsize = wxSize( size.ToSchUnits(), size.ToSchUnits() * 0.80 );
|
2017-09-12 14:06:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
textsize = wxSize( size.ToSchUnits(), size.ToSchUnits() );
|
2017-09-12 14:06:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
textsize = wxSize( size.ToSchUnits() * 0.85, size.ToSchUnits() );
|
2017-09-12 14:06:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return textsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-15 21:44:58 +00:00
|
|
|
EFRAME::EFRAME( wxXmlNode* aFrameNode )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* <!ELEMENT frame EMPTY>
|
|
|
|
* <!ATTLIST frame
|
|
|
|
* x1 %Coord; #REQUIRED
|
|
|
|
* y1 %Coord; #REQUIRED
|
|
|
|
* x2 %Coord; #REQUIRED
|
|
|
|
* y2 %Coord; #REQUIRED
|
|
|
|
* columns %Int; #REQUIRED
|
|
|
|
* rows %Int; #REQUIRED
|
|
|
|
* layer %Layer; #REQUIRED
|
|
|
|
* border-left %Bool; "yes"
|
|
|
|
* border-top %Bool; "yes"
|
|
|
|
* border-right %Bool; "yes"
|
|
|
|
* border-bottom %Bool; "yes"
|
|
|
|
* >
|
|
|
|
*/
|
|
|
|
border_left = true;
|
|
|
|
border_top = true;
|
|
|
|
border_right = true;
|
|
|
|
border_bottom = true;
|
|
|
|
|
|
|
|
x1 = parseRequiredAttribute<ECOORD>( aFrameNode, "x1" );
|
|
|
|
y1 = parseRequiredAttribute<ECOORD>( aFrameNode, "y1" );
|
|
|
|
x2 = parseRequiredAttribute<ECOORD>( aFrameNode, "x2" );
|
|
|
|
y2 = parseRequiredAttribute<ECOORD>( aFrameNode, "y2" );
|
|
|
|
columns = parseRequiredAttribute<int>( aFrameNode, "columns" );
|
|
|
|
rows = parseRequiredAttribute<int>( aFrameNode, "rows" );
|
|
|
|
layer = parseRequiredAttribute<int>( aFrameNode, "layer" );
|
|
|
|
border_left = parseOptionalAttribute<bool>( aFrameNode, "border-left" );
|
|
|
|
border_top = parseOptionalAttribute<bool>( aFrameNode, "border-top" );
|
|
|
|
border_right = parseOptionalAttribute<bool>( aFrameNode, "border-right" );
|
|
|
|
border_bottom = parseOptionalAttribute<bool>( aFrameNode, "border-bottom" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-13 13:34:53 +00:00
|
|
|
EPAD_COMMON::EPAD_COMMON( wxXmlNode* aPad )
|
|
|
|
{
|
|
|
|
// #REQUIRED says DTD, throw exception if not found
|
|
|
|
name = parseRequiredAttribute<wxString>( aPad, "name" );
|
|
|
|
x = parseRequiredAttribute<ECOORD>( aPad, "x" );
|
|
|
|
y = parseRequiredAttribute<ECOORD>( aPad, "y" );
|
|
|
|
rot = parseOptionalAttribute<EROT>( aPad, "rot" );
|
|
|
|
stop = parseOptionalAttribute<bool>( aPad, "stop" );
|
|
|
|
thermals = parseOptionalAttribute<bool>( aPad, "thermals" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
EPAD::EPAD( wxXmlNode* aPad )
|
2018-03-13 13:34:53 +00:00
|
|
|
: EPAD_COMMON( aPad )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT pad EMPTY>
|
|
|
|
<!ATTLIST pad
|
|
|
|
name %String; #REQUIRED
|
|
|
|
x %Coord; #REQUIRED
|
|
|
|
y %Coord; #REQUIRED
|
|
|
|
drill %Dimension; #REQUIRED
|
|
|
|
diameter %Dimension; "0"
|
|
|
|
shape %PadShape; "round"
|
|
|
|
rot %Rotation; "R0"
|
|
|
|
stop %Bool; "yes"
|
|
|
|
thermals %Bool; "yes"
|
|
|
|
first %Bool; "no"
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
|
|
|
// #REQUIRED says DTD, throw exception if not found
|
2017-10-17 08:18:54 +00:00
|
|
|
drill = parseRequiredAttribute<ECOORD>( aPad, "drill" );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
// Optional attributes
|
2017-10-17 08:18:54 +00:00
|
|
|
diameter = parseOptionalAttribute<ECOORD>( aPad, "diameter" );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
opt_wxString s = parseOptionalAttribute<wxString>( aPad, "shape" );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
// (square | round | octagon | long | offset)
|
|
|
|
if( s == "square" )
|
|
|
|
shape = EPAD::SQUARE;
|
|
|
|
else if( s == "round" )
|
|
|
|
shape = EPAD::ROUND;
|
|
|
|
else if( s == "octagon" )
|
|
|
|
shape = EPAD::OCTAGON;
|
|
|
|
else if( s == "long" )
|
|
|
|
shape = EPAD::LONG;
|
|
|
|
else if( s == "offset" )
|
|
|
|
shape = EPAD::OFFSET;
|
|
|
|
|
|
|
|
first = parseOptionalAttribute<bool>( aPad, "first" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ESMD::ESMD( wxXmlNode* aSMD )
|
2018-03-13 13:34:53 +00:00
|
|
|
: EPAD_COMMON( aSMD )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ATTLIST smd
|
|
|
|
name %String; #REQUIRED
|
|
|
|
x %Coord; #REQUIRED
|
|
|
|
y %Coord; #REQUIRED
|
|
|
|
dx %Dimension; #REQUIRED
|
|
|
|
dy %Dimension; #REQUIRED
|
|
|
|
layer %Layer; #REQUIRED
|
|
|
|
roundness %Int; "0"
|
|
|
|
rot %Rotation; "R0"
|
|
|
|
stop %Bool; "yes"
|
|
|
|
thermals %Bool; "yes"
|
|
|
|
cream %Bool; "yes"
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
|
|
|
// DTD #REQUIRED, throw exception if not found
|
2017-10-17 08:18:54 +00:00
|
|
|
dx = parseRequiredAttribute<ECOORD>( aSMD, "dx" );
|
|
|
|
dy = parseRequiredAttribute<ECOORD>( aSMD, "dy" );
|
2017-04-07 11:40:34 +00:00
|
|
|
layer = parseRequiredAttribute<int>( aSMD, "layer" );
|
|
|
|
|
|
|
|
roundness = parseOptionalAttribute<int>( aSMD, "roundness" );
|
|
|
|
cream = parseOptionalAttribute<bool>( aSMD, "cream" );
|
|
|
|
}
|
|
|
|
|
2017-06-19 13:43:55 +00:00
|
|
|
|
|
|
|
EPIN::EPIN( wxXmlNode* aPin )
|
|
|
|
{
|
2017-06-18 11:31:11 +00:00
|
|
|
/*
|
|
|
|
<!ELEMENT pin EMPTY>
|
|
|
|
<!ATTLIST pin
|
|
|
|
name %String; #REQUIRED
|
|
|
|
x %Coord; #REQUIRED
|
|
|
|
y %Coord; #REQUIRED
|
|
|
|
visible %PinVisible; "both"
|
|
|
|
length %PinLength; "long"
|
|
|
|
direction %PinDirection; "io"
|
|
|
|
function %PinFunction; "none"
|
|
|
|
swaplevel %Int; "0"
|
|
|
|
rot %Rotation; "R0"
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
|
|
|
// DTD #REQUIRED, throw exception if not found
|
2017-12-14 09:37:32 +00:00
|
|
|
name = parseRequiredAttribute<wxString>( aPin, "name" );
|
2017-10-17 08:18:54 +00:00
|
|
|
x = parseRequiredAttribute<ECOORD>( aPin, "x" );
|
|
|
|
y = parseRequiredAttribute<ECOORD>( aPin, "y" );
|
2017-06-18 11:31:11 +00:00
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
visible = parseOptionalAttribute<wxString>( aPin, "visible" );
|
|
|
|
length = parseOptionalAttribute<wxString>( aPin, "length" );
|
|
|
|
direction = parseOptionalAttribute<wxString>( aPin, "direction" );
|
|
|
|
function = parseOptionalAttribute<wxString>( aPin, "function" );
|
2017-06-19 13:43:55 +00:00
|
|
|
swaplevel = parseOptionalAttribute<int>( aPin, "swaplevel" );
|
|
|
|
rot = parseOptionalAttribute<EROT>( aPin, "rot" );
|
2017-06-18 11:31:11 +00:00
|
|
|
}
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2017-06-19 13:43:55 +00:00
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
EVERTEX::EVERTEX( wxXmlNode* aVertex )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT vertex EMPTY>
|
|
|
|
<!ATTLIST vertex
|
|
|
|
x %Coord; #REQUIRED
|
|
|
|
y %Coord; #REQUIRED
|
|
|
|
curve %WireCurve; "0" -- the curvature from this vertex to the next one --
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
x = parseRequiredAttribute<ECOORD>( aVertex, "x" );
|
|
|
|
y = parseRequiredAttribute<ECOORD>( aVertex, "y" );
|
2018-03-16 17:50:43 +00:00
|
|
|
curve = parseOptionalAttribute<double>( aVertex, "curve" );
|
2017-04-07 11:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EPOLYGON::EPOLYGON( wxXmlNode* aPolygon )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ATTLIST polygon
|
|
|
|
width %Dimension; #REQUIRED
|
|
|
|
layer %Layer; #REQUIRED
|
|
|
|
spacing %Dimension; #IMPLIED
|
|
|
|
pour %PolygonPour; "solid"
|
|
|
|
isolate %Dimension; #IMPLIED -- only in <signal> or <package> context --
|
|
|
|
orphans %Bool; "no" -- only in <signal> context --
|
|
|
|
thermals %Bool; "yes" -- only in <signal> context --
|
2021-02-15 21:44:58 +00:00
|
|
|
rank %Int; "0" -- 1..6 in <signal> context, 0 or 7 in
|
|
|
|
<package> context --
|
2017-04-07 11:40:34 +00:00
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
width = parseRequiredAttribute<ECOORD>( aPolygon, "width" );
|
2017-04-07 11:40:34 +00:00
|
|
|
layer = parseRequiredAttribute<int>( aPolygon, "layer" );
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
spacing = parseOptionalAttribute<ECOORD>( aPolygon, "spacing" );
|
|
|
|
isolate = parseOptionalAttribute<ECOORD>( aPolygon, "isolate" );
|
2017-12-14 09:37:32 +00:00
|
|
|
opt_wxString s = parseOptionalAttribute<wxString>( aPolygon, "pour" );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
// default pour to solid fill
|
|
|
|
pour = EPOLYGON::SOLID;
|
|
|
|
|
|
|
|
// (solid | hatch | cutout)
|
|
|
|
if( s == "hatch" )
|
|
|
|
pour = EPOLYGON::HATCH;
|
|
|
|
else if( s == "cutout" )
|
|
|
|
pour = EPOLYGON::CUTOUT;
|
|
|
|
|
|
|
|
orphans = parseOptionalAttribute<bool>( aPolygon, "orphans" );
|
|
|
|
thermals = parseOptionalAttribute<bool>( aPolygon, "thermals" );
|
|
|
|
rank = parseOptionalAttribute<int>( aPolygon, "rank" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EHOLE::EHOLE( wxXmlNode* aHole )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT hole EMPTY>
|
|
|
|
<!ATTLIST hole
|
|
|
|
x %Coord; #REQUIRED
|
|
|
|
y %Coord; #REQUIRED
|
|
|
|
drill %Dimension; #REQUIRED
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
|
|
|
// #REQUIRED:
|
2017-10-17 08:18:54 +00:00
|
|
|
x = parseRequiredAttribute<ECOORD>( aHole, "x" );
|
|
|
|
y = parseRequiredAttribute<ECOORD>( aHole, "y" );
|
|
|
|
drill = parseRequiredAttribute<ECOORD>( aHole, "drill" );
|
2017-04-07 11:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EELEMENT::EELEMENT( wxXmlNode* aElement )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT element (attribute*, variant*)>
|
|
|
|
<!ATTLIST element
|
|
|
|
name %String; #REQUIRED
|
|
|
|
library %String; #REQUIRED
|
|
|
|
package %String; #REQUIRED
|
|
|
|
value %String; #REQUIRED
|
|
|
|
x %Coord; #REQUIRED
|
|
|
|
y %Coord; #REQUIRED
|
|
|
|
locked %Bool; "no"
|
|
|
|
smashed %Bool; "no"
|
|
|
|
rot %Rotation; "R0"
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
|
|
|
// #REQUIRED
|
2017-12-14 09:37:32 +00:00
|
|
|
name = parseRequiredAttribute<wxString>( aElement, "name" );
|
|
|
|
library = parseRequiredAttribute<wxString>( aElement, "library" );
|
|
|
|
value = parseRequiredAttribute<wxString>( aElement, "value" );
|
|
|
|
std::string p = parseRequiredAttribute<std::string>( aElement, "package" );
|
2018-02-16 14:53:25 +00:00
|
|
|
ReplaceIllegalFileNameChars( &p, '_' );
|
2017-12-14 09:37:32 +00:00
|
|
|
package = wxString::FromUTF8( p.c_str() );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
x = parseRequiredAttribute<ECOORD>( aElement, "x" );
|
|
|
|
y = parseRequiredAttribute<ECOORD>( aElement, "y" );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
// optional
|
|
|
|
locked = parseOptionalAttribute<bool>( aElement, "locked" );
|
|
|
|
smashed = parseOptionalAttribute<bool>( aElement, "smashed" );
|
|
|
|
rot = parseOptionalAttribute<EROT>( aElement, "rot" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ELAYER::ELAYER( wxXmlNode* aLayer )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT layer EMPTY>
|
|
|
|
<!ATTLIST layer
|
|
|
|
number %Layer; #REQUIRED
|
|
|
|
name %String; #REQUIRED
|
|
|
|
color %Int; #REQUIRED
|
|
|
|
fill %Int; #REQUIRED
|
|
|
|
visible %Bool; "yes"
|
|
|
|
active %Bool; "yes"
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
|
|
|
number = parseRequiredAttribute<int>( aLayer, "number" );
|
2017-12-14 09:37:32 +00:00
|
|
|
name = parseRequiredAttribute<wxString>( aLayer, "name" );
|
2017-04-07 11:40:34 +00:00
|
|
|
color = parseRequiredAttribute<int>( aLayer, "color" );
|
|
|
|
fill = 1; // Temporary value.
|
|
|
|
visible = parseOptionalAttribute<bool>( aLayer, "visible" );
|
|
|
|
active = parseOptionalAttribute<bool>( aLayer, "active" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-26 07:53:57 +00:00
|
|
|
EPART::EPART( wxXmlNode* aPart )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* <!ELEMENT part (attribute*, variant*)>
|
|
|
|
* <!ATTLIST part
|
|
|
|
* name %String; #REQUIRED
|
|
|
|
* library %String; #REQUIRED
|
|
|
|
* deviceset %String; #REQUIRED
|
|
|
|
* device %String; #REQUIRED
|
|
|
|
* technology %String; ""
|
|
|
|
* value %String; #IMPLIED
|
|
|
|
* >
|
|
|
|
*/
|
|
|
|
// #REQUIRED
|
2017-12-14 09:37:32 +00:00
|
|
|
name = parseRequiredAttribute<wxString>( aPart, "name" );
|
|
|
|
library = parseRequiredAttribute<wxString>( aPart, "library" );
|
|
|
|
deviceset = parseRequiredAttribute<wxString>( aPart, "deviceset" );
|
|
|
|
device = parseRequiredAttribute<wxString>( aPart, "device" );
|
|
|
|
technology = parseOptionalAttribute<wxString>( aPart, "technology" );
|
|
|
|
value = parseOptionalAttribute<wxString>( aPart, "value" );
|
2018-07-10 14:32:10 +00:00
|
|
|
|
2021-09-20 11:36:57 +00:00
|
|
|
for( wxXmlNode* child = aPart->GetChildren(); child; child = child->GetNext() )
|
2018-07-10 14:32:10 +00:00
|
|
|
{
|
|
|
|
if( child->GetName() == "attribute" )
|
|
|
|
{
|
|
|
|
std::string aname, avalue;
|
|
|
|
|
2021-09-20 11:36:57 +00:00
|
|
|
for( wxXmlAttribute* x = child->GetAttributes(); x; x = x->GetNext() )
|
|
|
|
{
|
2018-07-10 14:32:10 +00:00
|
|
|
if( x->GetName() == "name" )
|
|
|
|
aname = x->GetValue();
|
|
|
|
else if( x->GetName() == "value" )
|
|
|
|
avalue = x->GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aname.size() && avalue.size() )
|
|
|
|
attribute[aname] = avalue;
|
|
|
|
}
|
|
|
|
else if( child->GetName() == "variant" )
|
|
|
|
{
|
|
|
|
std::string aname, avalue;
|
|
|
|
|
2021-09-20 11:36:57 +00:00
|
|
|
for( wxXmlAttribute* x = child->GetAttributes(); x; x = x->GetNext() )
|
|
|
|
{
|
2018-07-10 14:32:10 +00:00
|
|
|
if( x->GetName() == "name" )
|
|
|
|
aname = x->GetValue();
|
|
|
|
else if( x->GetName() == "value" )
|
|
|
|
avalue = x->GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aname.size() && avalue.size() )
|
|
|
|
variant[aname] = avalue;
|
|
|
|
}
|
|
|
|
}
|
2017-06-26 07:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EINSTANCE::EINSTANCE( wxXmlNode* aInstance )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* <!ELEMENT instance (attribute)*>
|
|
|
|
* <!ATTLIST instance
|
|
|
|
* part %String; #REQUIRED
|
|
|
|
* gate %String; #REQUIRED
|
|
|
|
* x %Coord; #REQUIRED
|
|
|
|
* y %Coord; #REQUIRED
|
|
|
|
* smashed %Bool; "no"
|
|
|
|
* rot %Rotation; "R0"
|
|
|
|
* >
|
|
|
|
*/
|
2017-12-14 09:37:32 +00:00
|
|
|
part = parseRequiredAttribute<wxString>( aInstance, "part" );
|
|
|
|
gate = parseRequiredAttribute<wxString>( aInstance, "gate" );
|
2017-06-26 07:53:57 +00:00
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
x = parseRequiredAttribute<ECOORD>( aInstance, "x" );
|
|
|
|
y = parseRequiredAttribute<ECOORD>( aInstance, "y" );
|
2017-06-26 07:53:57 +00:00
|
|
|
|
|
|
|
// optional
|
|
|
|
smashed = parseOptionalAttribute<bool>( aInstance, "smashed" );
|
|
|
|
rot = parseOptionalAttribute<EROT>( aInstance, "rot" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EGATE::EGATE( wxXmlNode* aGate )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* <!ELEMENT gate EMPTY>
|
|
|
|
* <!ATTLIST gate
|
|
|
|
* name %String; #REQUIRED
|
|
|
|
* symbol %String; #REQUIRED
|
|
|
|
* x %Coord; #REQUIRED
|
|
|
|
* y %Coord; #REQUIRED
|
|
|
|
* addlevel %GateAddLevel; "next"
|
|
|
|
* swaplevel %Int; "0"
|
|
|
|
* >
|
|
|
|
*/
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
name = parseRequiredAttribute<wxString>( aGate, "name" );
|
|
|
|
symbol = parseRequiredAttribute<wxString>( aGate, "symbol" );
|
2017-06-26 07:53:57 +00:00
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
x = parseRequiredAttribute<ECOORD>( aGate, "x" );
|
|
|
|
y = parseRequiredAttribute<ECOORD>( aGate, "y" );
|
2017-06-26 07:53:57 +00:00
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
opt_wxString stemp = parseOptionalAttribute<wxString>( aGate, "addlevel" );
|
2017-06-26 07:53:57 +00:00
|
|
|
|
|
|
|
// (off | value | name | both)
|
|
|
|
if( stemp == "must" )
|
|
|
|
addlevel = EGATE::MUST;
|
|
|
|
else if( stemp == "can" )
|
|
|
|
addlevel = EGATE::CAN;
|
|
|
|
else if( stemp == "next" )
|
|
|
|
addlevel = EGATE::NEXT;
|
|
|
|
else if( stemp == "request" )
|
|
|
|
addlevel = EGATE::REQUEST;
|
|
|
|
else if( stemp == "always" )
|
|
|
|
addlevel = EGATE::ALWAYS;
|
|
|
|
else
|
|
|
|
addlevel = EGATE::NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ECONNECT::ECONNECT( wxXmlNode* aConnect )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* <!ELEMENT connect EMPTY>
|
|
|
|
* <!ATTLIST connect
|
|
|
|
* gate %String; #REQUIRED
|
|
|
|
* pin %String; #REQUIRED
|
|
|
|
* pad %String; #REQUIRED
|
|
|
|
* route %ContactRoute; "all"
|
|
|
|
* >
|
|
|
|
*/
|
2017-12-14 09:37:32 +00:00
|
|
|
gate = parseRequiredAttribute<wxString>( aConnect, "gate" );
|
|
|
|
pin = parseRequiredAttribute<wxString>( aConnect, "pin" );
|
|
|
|
pad = parseRequiredAttribute<wxString>( aConnect, "pad" );
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2017-06-26 07:53:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
EDEVICE::EDEVICE( wxXmlNode* aDevice )
|
|
|
|
{
|
|
|
|
/*
|
2021-02-15 21:44:58 +00:00
|
|
|
<!ELEMENT device (connects?, technologies?)>
|
|
|
|
<!ATTLIST device
|
|
|
|
name %String; ""
|
|
|
|
package %String; #IMPLIED
|
|
|
|
>
|
|
|
|
*/
|
2017-12-14 09:37:32 +00:00
|
|
|
name = parseRequiredAttribute<wxString>( aDevice, "name" );
|
2018-02-16 14:53:25 +00:00
|
|
|
opt_wxString pack = parseOptionalAttribute<wxString>( aDevice, "package" );
|
2017-06-26 07:53:57 +00:00
|
|
|
|
2018-02-16 14:53:25 +00:00
|
|
|
if( pack )
|
|
|
|
{
|
|
|
|
std::string p( pack->c_str() );
|
|
|
|
ReplaceIllegalFileNameChars( &p, '_' );
|
|
|
|
package.Set( wxString::FromUTF8( p.c_str() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
NODE_MAP aDeviceChildren = MapChildren( aDevice );
|
|
|
|
wxXmlNode* connectNode = getChildrenNodes( aDeviceChildren, "connects" );
|
2017-06-26 07:53:57 +00:00
|
|
|
|
2018-02-16 14:53:25 +00:00
|
|
|
while( connectNode )
|
|
|
|
{
|
2019-12-05 15:41:21 +00:00
|
|
|
connects.emplace_back( connectNode );
|
2017-06-30 01:52:05 +00:00
|
|
|
connectNode = connectNode->GetNext();
|
2017-06-26 07:53:57 +00:00
|
|
|
}
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2017-06-26 07:53:57 +00:00
|
|
|
|
|
|
|
|
2017-10-03 10:23:52 +00:00
|
|
|
EDEVICE_SET::EDEVICE_SET( wxXmlNode* aDeviceSet )
|
2017-06-26 07:53:57 +00:00
|
|
|
{
|
|
|
|
/*
|
2021-02-15 21:44:58 +00:00
|
|
|
<!ELEMENT deviceset (description?, gates, devices)>
|
|
|
|
<!ATTLIST deviceset
|
2017-06-26 07:53:57 +00:00
|
|
|
name %String; #REQUIRED
|
|
|
|
prefix %String; ""
|
|
|
|
uservalue %Bool; "no"
|
|
|
|
>
|
2021-02-15 21:44:58 +00:00
|
|
|
*/
|
2017-06-26 07:53:57 +00:00
|
|
|
|
2021-09-20 11:36:57 +00:00
|
|
|
name = parseRequiredAttribute<wxString>( aDeviceSet, "name" );
|
2017-12-14 09:37:32 +00:00
|
|
|
prefix = parseOptionalAttribute<wxString>( aDeviceSet, "prefix" );
|
|
|
|
uservalue = parseOptionalAttribute<bool>( aDeviceSet, "uservalue" );
|
2017-06-26 07:53:57 +00:00
|
|
|
}
|
2021-09-20 11:36:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
ECLASS::ECLASS( wxXmlNode* aClass )
|
|
|
|
{
|
|
|
|
number = parseRequiredAttribute<wxString>( aClass, "number" );
|
|
|
|
name = parseRequiredAttribute<wxString>( aClass, "name" );
|
|
|
|
|
|
|
|
for( wxXmlNode* child = aClass->GetChildren(); child; child = child->GetNext() )
|
|
|
|
{
|
|
|
|
if( child->GetName() == "clearance" )
|
|
|
|
{
|
|
|
|
wxString to = parseRequiredAttribute<wxString>( child, "class" );
|
|
|
|
ECOORD value = parseRequiredAttribute<ECOORD>( child, "value" );
|
|
|
|
|
|
|
|
clearanceMap[to] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|