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-01-25 12:42:36 +00:00
|
|
|
* Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-05-08 14:27:11 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _EAGLE_PARSER_H_
|
|
|
|
#define _EAGLE_PARSER_H_
|
|
|
|
|
2020-10-24 04:00:49 +00:00
|
|
|
#include <map>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <memory>
|
2017-04-07 11:40:34 +00:00
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
#include <wx/xml/xml.h>
|
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/filename.h>
|
|
|
|
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2017-04-07 11:40:34 +00:00
|
|
|
#include <trigo.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <core/wx_stl_compat.h>
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2017-06-26 07:53:57 +00:00
|
|
|
struct EINSTANCE;
|
|
|
|
struct EPART;
|
2017-10-03 10:30:23 +00:00
|
|
|
struct ETEXT;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
typedef std::unordered_map<wxString, wxXmlNode*> NODE_MAP;
|
2020-11-13 15:15:52 +00:00
|
|
|
typedef std::map<wxString, FOOTPRINT*> FOOTPRINT_MAP;
|
2017-12-14 09:37:32 +00:00
|
|
|
typedef std::map<wxString, EINSTANCE*> EINSTANCE_MAP;
|
|
|
|
typedef std::map<wxString, std::unique_ptr<EPART>> EPART_MAP;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Translates Eagle special characters to their counterparts in KiCad.
|
2018-02-16 23:01:43 +00:00
|
|
|
wxString escapeName( const wxString& aNetName );
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
static inline wxXmlNode* getChildrenNodes( NODE_MAP& aMap, const wxString& aName )
|
2017-05-08 15:11:14 +00:00
|
|
|
{
|
|
|
|
auto it = aMap.find( aName );
|
|
|
|
return it == aMap.end() ? nullptr : it->second->GetChildren();
|
|
|
|
}
|
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Implement a simple wrapper around runtime_error to isolate the errors thrown by the
|
2017-04-07 11:40:34 +00:00
|
|
|
* Eagle XML parser.
|
|
|
|
*/
|
|
|
|
struct XML_PARSER_ERROR : std::runtime_error
|
|
|
|
{
|
|
|
|
/**
|
2021-02-15 21:44:58 +00:00
|
|
|
* Build an XML error by just calling its parent class constructor, std::runtime_error, with
|
2017-04-07 11:40:34 +00:00
|
|
|
* the passed message.
|
2021-02-15 21:44:58 +00:00
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @param aMessage is an explanatory error message.
|
|
|
|
*/
|
2017-12-14 09:37:32 +00:00
|
|
|
XML_PARSER_ERROR( const wxString& aMessage ) noexcept :
|
2017-12-17 19:16:23 +00:00
|
|
|
std::runtime_error( "XML parser failed - " + aMessage.ToStdString() )
|
2017-04-07 11:40:34 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// segment (element) of our XPATH into the Eagle XML document tree in PTREE form.
|
|
|
|
struct TRIPLET
|
|
|
|
{
|
|
|
|
const char* element;
|
|
|
|
const char* attribute;
|
|
|
|
const char* value;
|
|
|
|
|
|
|
|
TRIPLET( const char* aElement, const char* aAttribute = "", const char* aValue = "" ) :
|
|
|
|
element( aElement ),
|
|
|
|
attribute( aAttribute ),
|
|
|
|
value( aValue )
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Keep track of what we are working on within a PTREE.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* Then if an exception is thrown, the place within the tree that gave us
|
|
|
|
* grief can be reported almost accurately. To minimally impact
|
|
|
|
* speed, merely assign const char* pointers during the tree walking
|
|
|
|
* expedition. The const char* pointers must be to C strings residing either in
|
|
|
|
* the data or code segment (i.e. "compiled in") or within the XML document, but
|
|
|
|
* not on the stack, since the stack is unwound during the throwing of the
|
|
|
|
* exception. The XML document will not immediately vanish since we capture
|
|
|
|
* the xpath (using function Contents()) before the XML document tree (PTREE)
|
|
|
|
* is destroyed.
|
|
|
|
*/
|
|
|
|
class XPATH
|
|
|
|
{
|
2017-05-08 14:27:11 +00:00
|
|
|
std::vector<TRIPLET> p;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
void push( const char* aPathSegment, const char* aAttribute="" )
|
|
|
|
{
|
2019-12-05 15:41:21 +00:00
|
|
|
p.emplace_back( aPathSegment, aAttribute );
|
2017-04-07 11:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void clear() { p.clear(); }
|
|
|
|
|
|
|
|
void pop() { p.pop_back(); }
|
|
|
|
|
|
|
|
/// modify the last path node's value
|
|
|
|
void Value( const char* aValue )
|
|
|
|
{
|
|
|
|
p.back().value = aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// modify the last path node's attribute
|
|
|
|
void Attribute( const char* aAttribute )
|
|
|
|
{
|
|
|
|
p.back().attribute = aAttribute;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// return the contents of the XPATH as a single string
|
2017-12-14 09:37:32 +00:00
|
|
|
wxString Contents()
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
|
|
|
typedef std::vector<TRIPLET>::const_iterator CITER_TRIPLET;
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
wxString ret;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
for( CITER_TRIPLET it = p.begin(); it != p.end(); ++it )
|
|
|
|
{
|
|
|
|
if( it != p.begin() )
|
|
|
|
ret += '.';
|
|
|
|
|
|
|
|
ret += it->element;
|
|
|
|
|
|
|
|
if( it->attribute[0] && it->value[0] )
|
|
|
|
{
|
|
|
|
ret += '[';
|
|
|
|
ret += it->attribute;
|
|
|
|
ret += '=';
|
|
|
|
ret += it->value;
|
|
|
|
ret += ']';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Convert a wxString to a generic type T.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @param aValue is a wxString containing the value that will be converted to type T.
|
|
|
|
* @throw XML_PARSER_ERROR - an exception is thrown if the parsing fails or if the conversion to
|
|
|
|
* type T is unknown.
|
|
|
|
*/
|
|
|
|
template<typename T>
|
2017-09-02 01:04:25 +00:00
|
|
|
T Convert( const wxString& aValue )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
|
|
|
throw XML_PARSER_ERROR( "Conversion failed. Unknown type." );
|
|
|
|
}
|
|
|
|
|
2017-12-18 16:45:40 +00:00
|
|
|
template <>
|
|
|
|
wxString Convert<wxString>( const wxString& aValue );
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Model an optional XML attribute.
|
|
|
|
*
|
2017-11-01 11:14:16 +00:00
|
|
|
* This was implemented as an alternative to OPT. This class should be replaced with a
|
2017-04-07 11:40:34 +00:00
|
|
|
* simple typedef per type using std::optional when C++17 is published.
|
|
|
|
*/
|
2017-12-14 09:37:32 +00:00
|
|
|
template <typename T>
|
2017-04-07 11:40:34 +00:00
|
|
|
class OPTIONAL_XML_ATTRIBUTE
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
/// A boolean indicating if the data is present or not.
|
|
|
|
bool m_isAvailable;
|
|
|
|
|
|
|
|
/// The actual data if m_isAvailable is true; otherwise, garbage.
|
|
|
|
T m_data;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Construct a default OPTIONAL_XML_ATTRIBUTE, whose data is not available.
|
2017-04-07 11:40:34 +00:00
|
|
|
*/
|
|
|
|
OPTIONAL_XML_ATTRIBUTE() :
|
2018-01-06 05:02:28 +00:00
|
|
|
m_isAvailable( false ),
|
|
|
|
m_data( T() )
|
2017-04-07 11:40:34 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aData is a wxString containing the value that should be converted to type T. If
|
|
|
|
* aData is empty, the attribute is understood as unavailable; otherwise, the
|
|
|
|
* conversion to T is tried.
|
|
|
|
*/
|
2017-10-03 10:23:52 +00:00
|
|
|
OPTIONAL_XML_ATTRIBUTE( const wxString& aData )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
2018-06-04 17:48:17 +00:00
|
|
|
m_data = T();
|
2017-04-07 11:40:34 +00:00
|
|
|
m_isAvailable = !aData.IsEmpty();
|
|
|
|
|
|
|
|
if( m_isAvailable )
|
|
|
|
Set( aData );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aData is the value of the XML attribute. If this constructor is called, the
|
|
|
|
* attribute is available.
|
|
|
|
*/
|
2017-12-14 09:37:32 +00:00
|
|
|
template<typename V = T>
|
2017-04-07 11:40:34 +00:00
|
|
|
OPTIONAL_XML_ATTRIBUTE( T aData ) :
|
|
|
|
m_isAvailable( true ),
|
|
|
|
m_data( aData )
|
|
|
|
{}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* @return bool the availability of the attribute.
|
2017-04-07 11:40:34 +00:00
|
|
|
*/
|
|
|
|
operator bool() const
|
|
|
|
{
|
|
|
|
return m_isAvailable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Assign to a string (optionally) containing the data.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @param aData is a wxString that should be converted to T. If the string is empty, the
|
|
|
|
* attribute is set to unavailable.
|
|
|
|
*/
|
2017-10-03 10:23:52 +00:00
|
|
|
OPTIONAL_XML_ATTRIBUTE<T>& operator =( const wxString& aData )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
|
|
|
m_isAvailable = !aData.IsEmpty();
|
|
|
|
|
|
|
|
if( m_isAvailable )
|
|
|
|
Set( aData );
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Assign to an object of the base type containing the data.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @param aData is the actual value of the attribute. Calling this assignment, the attribute
|
|
|
|
* is automatically made available.
|
|
|
|
*/
|
|
|
|
OPTIONAL_XML_ATTRIBUTE<T>& operator =( T aData )
|
|
|
|
{
|
|
|
|
m_data = aData;
|
|
|
|
m_isAvailable = true;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aOther is the object of the base type that should be compared with this one.
|
|
|
|
*/
|
|
|
|
bool operator ==( const T& aOther ) const
|
|
|
|
{
|
|
|
|
return m_isAvailable && ( aOther == m_data );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Attempt to convert a string to the base type.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @param aString is the string that will be converted to the base type.
|
|
|
|
*/
|
2017-10-03 10:23:52 +00:00
|
|
|
void Set( const wxString& aString )
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
|
|
|
m_data = Convert<T>( aString );
|
2018-02-16 14:53:25 +00:00
|
|
|
m_isAvailable = !aString.IsEmpty();
|
2017-04-07 11:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Return a reference to the value of the attribute assuming it is available.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @return T& - the value of the attribute.
|
|
|
|
*/
|
|
|
|
T& Get()
|
|
|
|
{
|
|
|
|
assert( m_isAvailable );
|
|
|
|
return m_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Return a constant reference to the value of the attribute assuming it is available.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @return const T& - the value of the attribute.
|
|
|
|
*/
|
|
|
|
const T& CGet() const
|
|
|
|
{
|
|
|
|
assert( m_isAvailable );
|
|
|
|
return m_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Return a reference to the value of the attribute assuming it is available.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @return T& - the value of the attribute.
|
|
|
|
*/
|
|
|
|
T& operator*()
|
|
|
|
{
|
|
|
|
return Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Return a constant reference to the value of the attribute assuming it is available.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @return const T& - the value of the attribute.
|
|
|
|
*/
|
|
|
|
const T& operator*() const
|
|
|
|
{
|
|
|
|
return CGet();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Return a pointer to the value of the attribute assuming it is available.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @return T* - the value of the attribute.
|
|
|
|
*/
|
|
|
|
T* operator->()
|
|
|
|
{
|
|
|
|
return &Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Return a constant pointer to the value of the attribute assuming it is available.
|
|
|
|
*
|
2017-04-07 11:40:34 +00:00
|
|
|
* @return const T* - the value of the attribute.
|
|
|
|
*/
|
|
|
|
const T* operator->() const
|
|
|
|
{
|
|
|
|
return &CGet();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-06-26 07:51:51 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Provide an easy access to the children of an XML node via their names.
|
|
|
|
*
|
2017-06-26 07:51:51 +00:00
|
|
|
* @param currentNode is a pointer to a wxXmlNode, whose children will be mapped.
|
2021-01-25 12:42:36 +00:00
|
|
|
* @return NODE_MAP is a map linking the name of each children to the children itself (via a
|
2017-06-26 07:51:51 +00:00
|
|
|
* wxXmlNode*)
|
|
|
|
*/
|
2017-10-03 10:30:23 +00:00
|
|
|
NODE_MAP MapChildren( wxXmlNode* aCurrentNode );
|
2017-06-26 07:51:51 +00:00
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Convert an Eagle curve end to a KiCad center for S_ARC
|
2017-10-03 10:30:23 +00:00
|
|
|
wxPoint ConvertArcCenter( const wxPoint& aStart, const wxPoint& aEnd, double aAngle );
|
2017-06-26 07:51:51 +00:00
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
// Pre-declare for typedefs
|
|
|
|
struct EROT;
|
2017-10-17 08:18:54 +00:00
|
|
|
struct ECOORD;
|
2017-12-14 09:37:32 +00:00
|
|
|
typedef OPTIONAL_XML_ATTRIBUTE<wxString> opt_wxString;
|
2017-04-07 11:40:34 +00:00
|
|
|
typedef OPTIONAL_XML_ATTRIBUTE<int> opt_int;
|
|
|
|
typedef OPTIONAL_XML_ATTRIBUTE<double> opt_double;
|
|
|
|
typedef OPTIONAL_XML_ATTRIBUTE<bool> opt_bool;
|
|
|
|
typedef OPTIONAL_XML_ATTRIBUTE<EROT> opt_erot;
|
2017-10-17 08:18:54 +00:00
|
|
|
typedef OPTIONAL_XML_ATTRIBUTE<ECOORD> opt_ecoord;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
// All of the 'E'STRUCTS below merely hold Eagle XML information verbatim, in binary.
|
|
|
|
// For maintenance and troubleshooting purposes, it was thought that we'd need to
|
|
|
|
// separate the conversion process into distinct steps. There is no intent to have KiCad
|
|
|
|
// forms of information in these 'E'STRUCTS. They are only binary forms
|
|
|
|
// of the Eagle information in the corresponding Eagle XML nodes.
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
// Eagle coordinates
|
|
|
|
struct ECOORD
|
|
|
|
{
|
2017-10-23 13:37:24 +00:00
|
|
|
enum EAGLE_UNIT
|
2017-10-17 08:18:54 +00:00
|
|
|
{
|
2018-03-13 12:54:08 +00:00
|
|
|
EU_NM, ///< nanometers
|
|
|
|
EU_MM, ///< millimeters
|
|
|
|
EU_INCH, ///< inches
|
|
|
|
EU_MIL, ///< mils/thous
|
2017-10-17 08:18:54 +00:00
|
|
|
};
|
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Value expressed in nanometers
|
2017-10-17 08:18:54 +00:00
|
|
|
long long int value;
|
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Unit used for the value field
|
2018-03-13 12:54:08 +00:00
|
|
|
static constexpr EAGLE_UNIT ECOORD_UNIT = EU_NM;
|
2017-10-17 08:18:54 +00:00
|
|
|
|
|
|
|
ECOORD()
|
|
|
|
: value( 0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-23 13:37:24 +00:00
|
|
|
ECOORD( int aValue, enum EAGLE_UNIT aUnit )
|
2018-03-13 12:54:08 +00:00
|
|
|
: value( ConvertToNm( aValue, aUnit ) )
|
2017-10-17 08:18:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-23 13:37:24 +00:00
|
|
|
ECOORD( const wxString& aValue, enum EAGLE_UNIT aUnit );
|
2017-10-17 08:18:54 +00:00
|
|
|
|
2018-03-13 12:54:08 +00:00
|
|
|
int ToMils() const
|
2017-10-17 08:18:54 +00:00
|
|
|
{
|
|
|
|
return value / 25400;
|
|
|
|
}
|
|
|
|
|
2020-01-05 19:11:15 +00:00
|
|
|
int To100NanoMeters() const
|
|
|
|
{
|
|
|
|
return value / 100;
|
|
|
|
}
|
|
|
|
|
2018-03-13 12:54:08 +00:00
|
|
|
int ToNanoMeters() const
|
2017-10-17 08:18:54 +00:00
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2017-10-18 07:53:07 +00:00
|
|
|
float ToMm() const
|
|
|
|
{
|
|
|
|
return value / 1000000.0;
|
|
|
|
}
|
|
|
|
|
2020-01-05 19:11:15 +00:00
|
|
|
int ToSchUnits() const { return To100NanoMeters(); }
|
2018-03-13 12:54:08 +00:00
|
|
|
int ToPcbUnits() const { return ToNanoMeters(); }
|
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD operator+( const ECOORD& aOther ) const
|
|
|
|
{
|
|
|
|
return ECOORD( value + aOther.value, ECOORD_UNIT );
|
|
|
|
}
|
|
|
|
|
|
|
|
ECOORD operator-( const ECOORD& aOther ) const
|
|
|
|
{
|
|
|
|
return ECOORD( value - aOther.value, ECOORD_UNIT );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==( const ECOORD& aOther ) const
|
|
|
|
{
|
|
|
|
return value == aOther.value;
|
|
|
|
}
|
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Converts a size expressed in a certain unit to nanometers.
|
2018-03-13 12:54:08 +00:00
|
|
|
static long long int ConvertToNm( int aValue, enum EAGLE_UNIT aUnit );
|
2017-10-17 08:18:54 +00:00
|
|
|
};
|
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
/// Eagle net
|
|
|
|
struct ENET
|
|
|
|
{
|
2017-10-17 08:19:43 +00:00
|
|
|
int netcode;
|
2017-12-14 09:37:32 +00:00
|
|
|
wxString netname;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
ENET( int aNetCode, const wxString& aNetName ) :
|
2017-04-07 11:40:34 +00:00
|
|
|
netcode( aNetCode ),
|
|
|
|
netname( aNetName )
|
|
|
|
{}
|
|
|
|
|
|
|
|
ENET() :
|
|
|
|
netcode( 0 )
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Eagle rotation
|
|
|
|
struct EROT
|
|
|
|
{
|
|
|
|
bool mirror;
|
|
|
|
bool spin;
|
|
|
|
double degrees;
|
|
|
|
|
|
|
|
EROT() :
|
|
|
|
mirror( false ),
|
|
|
|
spin( false ),
|
|
|
|
degrees( 0 )
|
|
|
|
{}
|
|
|
|
|
|
|
|
EROT( double aDegrees ) :
|
|
|
|
mirror( false ),
|
|
|
|
spin( false ),
|
|
|
|
degrees( aDegrees )
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Eagle wire
|
|
|
|
struct EWIRE
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x1;
|
|
|
|
ECOORD y1;
|
|
|
|
ECOORD x2;
|
|
|
|
ECOORD y2;
|
|
|
|
ECOORD width;
|
2017-04-07 11:40:34 +00:00
|
|
|
LAYER_NUM layer;
|
|
|
|
|
|
|
|
// for style: (continuous | longdash | shortdash | dashdot)
|
|
|
|
enum {
|
|
|
|
CONTINUOUS,
|
|
|
|
LONGDASH,
|
|
|
|
SHORTDASH,
|
|
|
|
DASHDOT,
|
|
|
|
};
|
|
|
|
opt_int style;
|
|
|
|
opt_double curve; ///< range is -359.9..359.9
|
|
|
|
|
|
|
|
// for cap: (flat | round)
|
|
|
|
enum {
|
|
|
|
FLAT,
|
|
|
|
ROUND,
|
|
|
|
};
|
|
|
|
opt_int cap;
|
|
|
|
|
|
|
|
EWIRE( wxXmlNode* aWire );
|
|
|
|
};
|
|
|
|
|
2017-10-03 10:30:23 +00:00
|
|
|
|
2017-06-18 11:31:11 +00:00
|
|
|
/// Eagle Junction
|
|
|
|
struct EJUNCTION
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x;
|
|
|
|
ECOORD y;
|
2017-06-18 11:31:11 +00:00
|
|
|
|
|
|
|
EJUNCTION( wxXmlNode* aJunction);
|
|
|
|
};
|
|
|
|
|
2017-10-03 10:30:23 +00:00
|
|
|
|
2017-06-18 11:31:11 +00:00
|
|
|
/// Eagle label
|
|
|
|
struct ELABEL
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x;
|
|
|
|
ECOORD y;
|
|
|
|
ECOORD size;
|
2017-06-18 11:31:11 +00:00
|
|
|
LAYER_NUM layer;
|
|
|
|
opt_erot rot;
|
2017-12-14 09:37:32 +00:00
|
|
|
opt_wxString xref;
|
2017-06-18 11:31:11 +00:00
|
|
|
wxString netname;
|
|
|
|
|
2017-06-19 13:43:25 +00:00
|
|
|
ELABEL( wxXmlNode* aLabel, const wxString& aNetName );
|
2017-06-18 11:31:11 +00:00
|
|
|
};
|
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
/// Eagle via
|
|
|
|
struct EVIA
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x;
|
|
|
|
ECOORD y;
|
2017-04-07 11:40:34 +00:00
|
|
|
int layer_front_most; /// < extent
|
|
|
|
int layer_back_most; /// < inclusive
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD drill;
|
|
|
|
opt_ecoord diam;
|
2017-12-14 09:37:32 +00:00
|
|
|
opt_wxString shape;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
EVIA( wxXmlNode* aVia );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Eagle circle
|
|
|
|
struct ECIRCLE
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x;
|
|
|
|
ECOORD y;
|
|
|
|
ECOORD radius;
|
|
|
|
ECOORD width;
|
2017-04-07 11:40:34 +00:00
|
|
|
LAYER_NUM layer;
|
|
|
|
|
|
|
|
ECIRCLE( wxXmlNode* aCircle );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Eagle XML rectangle in binary
|
|
|
|
struct ERECT
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x1;
|
|
|
|
ECOORD y1;
|
|
|
|
ECOORD x2;
|
|
|
|
ECOORD y2;
|
2017-04-07 11:40:34 +00:00
|
|
|
int layer;
|
|
|
|
opt_erot rot;
|
|
|
|
|
|
|
|
ERECT( wxXmlNode* aRect );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Parse an Eagle "attribute" XML element.
|
|
|
|
*
|
|
|
|
* @note An attribute element is different than an XML element attribute. The attribute element
|
|
|
|
* is a full XML node in and of itself, and has attributes of its own. Blame Eagle.
|
2017-04-07 11:40:34 +00:00
|
|
|
*/
|
|
|
|
struct EATTR
|
|
|
|
{
|
2017-12-14 09:37:32 +00:00
|
|
|
wxString name;
|
|
|
|
opt_wxString value;
|
2017-10-17 08:18:54 +00:00
|
|
|
opt_ecoord x;
|
|
|
|
opt_ecoord y;
|
|
|
|
opt_ecoord size;
|
2017-04-07 11:40:34 +00:00
|
|
|
opt_int layer;
|
|
|
|
opt_double ratio;
|
|
|
|
opt_erot rot;
|
|
|
|
|
|
|
|
enum { // for 'display'
|
|
|
|
Off,
|
|
|
|
VALUE,
|
|
|
|
NAME,
|
|
|
|
BOTH,
|
|
|
|
};
|
|
|
|
opt_int display;
|
2017-07-16 16:12:05 +00:00
|
|
|
opt_int align;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
EATTR( wxXmlNode* aTree );
|
|
|
|
EATTR() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Eagle dimension element
|
|
|
|
struct EDIMENSION
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x1;
|
|
|
|
ECOORD y1;
|
|
|
|
ECOORD x2;
|
|
|
|
ECOORD y2;
|
|
|
|
ECOORD x3;
|
|
|
|
ECOORD y3;
|
2017-04-07 11:40:34 +00:00
|
|
|
int layer;
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
opt_wxString dimensionType;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
EDIMENSION( wxXmlNode* aDimension );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Eagle text element
|
|
|
|
struct ETEXT
|
|
|
|
{
|
2017-12-14 09:37:32 +00:00
|
|
|
wxString text;
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x;
|
|
|
|
ECOORD y;
|
|
|
|
ECOORD size;
|
2017-04-07 11:40:34 +00:00
|
|
|
int layer;
|
2017-12-14 09:37:32 +00:00
|
|
|
opt_wxString font;
|
2017-04-07 11:40:34 +00:00
|
|
|
opt_double ratio;
|
|
|
|
opt_erot rot;
|
|
|
|
|
|
|
|
enum { // for align
|
2021-10-27 12:54:28 +00:00
|
|
|
CENTER = 0,
|
2017-04-07 11:40:34 +00:00
|
|
|
CENTER_LEFT,
|
|
|
|
TOP_CENTER,
|
|
|
|
TOP_LEFT,
|
|
|
|
TOP_RIGHT,
|
|
|
|
|
|
|
|
// opposites are -1 x above, used by code tricks in here
|
|
|
|
CENTER_RIGHT = -CENTER_LEFT,
|
|
|
|
BOTTOM_CENTER = -TOP_CENTER,
|
|
|
|
BOTTOM_LEFT = -TOP_RIGHT,
|
|
|
|
BOTTOM_RIGHT = -TOP_LEFT,
|
|
|
|
};
|
|
|
|
|
2017-10-03 10:30:23 +00:00
|
|
|
opt_int align;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
ETEXT( wxXmlNode* aText );
|
2017-09-12 14:06:54 +00:00
|
|
|
|
|
|
|
/// Calculate text size based on font type and size
|
|
|
|
wxSize ConvertSize() const;
|
2017-04-07 11:40:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-02-15 21:44:58 +00:00
|
|
|
/**
|
|
|
|
* Parse an Eagle frame element.
|
|
|
|
*/
|
|
|
|
struct EFRAME
|
|
|
|
{
|
|
|
|
ECOORD x1;
|
|
|
|
ECOORD y1;
|
|
|
|
ECOORD x2;
|
|
|
|
ECOORD y2;
|
|
|
|
int columns;
|
|
|
|
int rows;
|
|
|
|
int layer;
|
|
|
|
opt_bool border_left;
|
|
|
|
opt_bool border_top;
|
|
|
|
opt_bool border_right;
|
|
|
|
opt_bool border_bottom;
|
|
|
|
|
|
|
|
EFRAME( wxXmlNode* aFrameNode );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-03-13 13:34:53 +00:00
|
|
|
/// Structure holding common properties for through-hole and SMD pads
|
|
|
|
struct EPAD_COMMON
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
2017-12-14 09:37:32 +00:00
|
|
|
wxString name;
|
2018-03-13 13:34:53 +00:00
|
|
|
ECOORD x, y;
|
|
|
|
opt_erot rot;
|
|
|
|
opt_bool stop;
|
|
|
|
opt_bool thermals;
|
|
|
|
|
|
|
|
EPAD_COMMON( wxXmlNode* aPad );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Eagle thru hole pad
|
|
|
|
struct EPAD : public EPAD_COMMON
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD drill;
|
|
|
|
opt_ecoord diameter;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
// for shape: (square | round | octagon | long | offset)
|
|
|
|
enum {
|
2019-02-04 01:46:10 +00:00
|
|
|
UNDEF = -1,
|
2017-04-07 11:40:34 +00:00
|
|
|
SQUARE,
|
|
|
|
ROUND,
|
|
|
|
OCTAGON,
|
|
|
|
LONG,
|
|
|
|
OFFSET,
|
|
|
|
};
|
|
|
|
opt_int shape;
|
|
|
|
opt_bool first;
|
|
|
|
|
|
|
|
EPAD( wxXmlNode* aPad );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Eagle SMD pad
|
2018-03-13 13:34:53 +00:00
|
|
|
struct ESMD : public EPAD_COMMON
|
2017-04-07 11:40:34 +00:00
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD dx;
|
|
|
|
ECOORD dy;
|
2017-04-07 11:40:34 +00:00
|
|
|
int layer;
|
|
|
|
opt_int roundness;
|
|
|
|
opt_bool cream;
|
|
|
|
|
|
|
|
ESMD( wxXmlNode* aSMD );
|
|
|
|
};
|
|
|
|
|
2017-10-03 10:30:23 +00:00
|
|
|
|
2017-06-18 11:31:11 +00:00
|
|
|
/// Eagle pin element
|
|
|
|
struct EPIN
|
|
|
|
{
|
2017-12-14 09:37:32 +00:00
|
|
|
wxString name;
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x;
|
|
|
|
ECOORD y;
|
2017-06-18 11:31:11 +00:00
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
opt_wxString visible;
|
|
|
|
opt_wxString length;
|
|
|
|
opt_wxString direction;
|
|
|
|
opt_wxString function;
|
2017-06-18 11:31:11 +00:00
|
|
|
opt_int swaplevel;
|
|
|
|
opt_erot rot;
|
|
|
|
|
|
|
|
EPIN( wxXmlNode* aPin );
|
|
|
|
};
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2017-10-03 10:30:23 +00:00
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
/// Eagle vertex
|
|
|
|
struct EVERTEX
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x;
|
|
|
|
ECOORD y;
|
2018-03-16 17:50:43 +00:00
|
|
|
opt_double curve; ///< range is -359.9..359.9
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
EVERTEX( wxXmlNode* aVertex );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Eagle polygon, without vertices which are parsed as needed
|
|
|
|
struct EPOLYGON
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD width;
|
2017-04-07 11:40:34 +00:00
|
|
|
int layer;
|
2017-10-17 08:18:54 +00:00
|
|
|
opt_ecoord spacing;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
// KiCad priority is opposite of Eagle rank, that is:
|
|
|
|
// - Eagle Low rank drawn first
|
|
|
|
// - KiCad high priority drawn first
|
|
|
|
// So since Eagle has an upper limit we define this, used for the cases
|
|
|
|
// where no rank is specified.
|
|
|
|
static const int max_priority = 6;
|
|
|
|
|
|
|
|
enum { // for pour
|
|
|
|
SOLID,
|
|
|
|
HATCH,
|
|
|
|
CUTOUT,
|
|
|
|
};
|
|
|
|
int pour;
|
2017-10-17 08:18:54 +00:00
|
|
|
opt_ecoord isolate;
|
2017-04-07 11:40:34 +00:00
|
|
|
opt_bool orphans;
|
|
|
|
opt_bool thermals;
|
|
|
|
opt_int rank;
|
|
|
|
|
|
|
|
EPOLYGON( wxXmlNode* aPolygon );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Eagle hole element
|
|
|
|
struct EHOLE
|
|
|
|
{
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x;
|
|
|
|
ECOORD y;
|
|
|
|
ECOORD drill;
|
2017-04-07 11:40:34 +00:00
|
|
|
|
|
|
|
EHOLE( wxXmlNode* aHole );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Eagle element element
|
|
|
|
struct EELEMENT
|
|
|
|
{
|
2017-12-14 09:37:32 +00:00
|
|
|
wxString name;
|
|
|
|
wxString library;
|
|
|
|
wxString package;
|
|
|
|
wxString value;
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x;
|
|
|
|
ECOORD y;
|
2017-04-07 11:40:34 +00:00
|
|
|
opt_bool locked;
|
|
|
|
opt_bool smashed;
|
|
|
|
opt_erot rot;
|
|
|
|
|
|
|
|
EELEMENT( wxXmlNode* aElement );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct ELAYER
|
|
|
|
{
|
|
|
|
int number;
|
2017-12-14 09:37:32 +00:00
|
|
|
wxString name;
|
2017-04-07 11:40:34 +00:00
|
|
|
int color;
|
|
|
|
int fill;
|
|
|
|
opt_bool visible;
|
|
|
|
opt_bool active;
|
|
|
|
|
|
|
|
ELAYER( wxXmlNode* aLayer );
|
|
|
|
};
|
|
|
|
|
2017-05-08 08:26:48 +00:00
|
|
|
|
|
|
|
struct EAGLE_LAYER
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TOP = 1,
|
|
|
|
ROUTE2 = 2,
|
|
|
|
ROUTE3 = 3,
|
|
|
|
ROUTE4 = 4,
|
|
|
|
ROUTE5 = 5,
|
|
|
|
ROUTE6 = 6,
|
|
|
|
ROUTE7 = 7,
|
|
|
|
ROUTE8 = 8,
|
|
|
|
ROUTE9 = 9,
|
|
|
|
ROUTE10 = 10,
|
|
|
|
ROUTE11 = 11,
|
|
|
|
ROUTE12 = 12,
|
|
|
|
ROUTE13 = 13,
|
|
|
|
ROUTE14 = 14,
|
|
|
|
ROUTE15 = 15,
|
|
|
|
BOTTOM = 16,
|
|
|
|
PADS = 17,
|
|
|
|
VIAS = 18,
|
|
|
|
UNROUTED = 19,
|
|
|
|
DIMENSION = 20,
|
|
|
|
TPLACE = 21,
|
|
|
|
BPLACE = 22,
|
|
|
|
TORIGINS = 23,
|
|
|
|
BORIGINS = 24,
|
|
|
|
TNAMES = 25,
|
|
|
|
BNAMES = 26,
|
|
|
|
TVALUES = 27,
|
|
|
|
BVALUES = 28,
|
|
|
|
TSTOP = 29,
|
|
|
|
BSTOP = 30,
|
|
|
|
TCREAM = 31,
|
|
|
|
BCREAM = 32,
|
|
|
|
TFINISH = 33,
|
|
|
|
BFINISH = 34,
|
|
|
|
TGLUE = 35,
|
|
|
|
BGLUE = 36,
|
|
|
|
TTEST = 37,
|
|
|
|
BTEST = 38,
|
|
|
|
TKEEPOUT = 39,
|
|
|
|
BKEEPOUT = 40,
|
|
|
|
TRESTRICT = 41,
|
|
|
|
BRESTRICT = 42,
|
|
|
|
VRESTRICT = 43,
|
|
|
|
DRILLS = 44,
|
|
|
|
HOLES = 45,
|
|
|
|
MILLING = 46,
|
|
|
|
MEASURES = 47,
|
|
|
|
DOCUMENT = 48,
|
|
|
|
REFERENCELC = 49,
|
|
|
|
REFERENCELS = 50,
|
|
|
|
TDOCU = 51,
|
|
|
|
BDOCU = 52,
|
|
|
|
NETS = 91,
|
|
|
|
BUSSES = 92,
|
|
|
|
PINS = 93,
|
|
|
|
SYMBOLS = 94,
|
|
|
|
NAMES = 95,
|
|
|
|
VALUES = 96,
|
|
|
|
INFO = 97,
|
|
|
|
GUIDE = 98,
|
|
|
|
USERLAYER1 = 160,
|
|
|
|
USERLAYER2 = 161
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
|
2017-06-26 07:53:57 +00:00
|
|
|
struct EPART
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* <!ELEMENT part (attribute*, variant*)>
|
|
|
|
* <!ATTLIST part
|
|
|
|
* name %String; #REQUIRED
|
|
|
|
* library %String; #REQUIRED
|
|
|
|
* deviceset %String; #REQUIRED
|
|
|
|
* device %String; #REQUIRED
|
|
|
|
* technology %String; ""
|
|
|
|
* value %String; #IMPLIED
|
|
|
|
* >
|
|
|
|
*/
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
wxString name;
|
|
|
|
wxString library;
|
|
|
|
wxString deviceset;
|
|
|
|
wxString device;
|
|
|
|
opt_wxString technology;
|
|
|
|
opt_wxString value;
|
2018-07-10 14:32:10 +00:00
|
|
|
std::map<std::string,std::string> attribute;
|
|
|
|
std::map<std::string,std::string> variant;
|
2017-06-26 07:53:57 +00:00
|
|
|
|
|
|
|
EPART( wxXmlNode* aPart );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct EINSTANCE
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* <!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
|
|
|
wxString part;
|
|
|
|
wxString gate;
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x;
|
|
|
|
ECOORD y;
|
2017-06-26 07:53:57 +00:00
|
|
|
opt_bool smashed;
|
|
|
|
opt_erot rot;
|
|
|
|
|
|
|
|
EINSTANCE( wxXmlNode* aInstance );
|
|
|
|
};
|
|
|
|
|
2017-10-03 10:30:23 +00:00
|
|
|
|
2017-06-26 07:53:57 +00:00
|
|
|
struct EGATE
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* <!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
|
|
|
wxString name;
|
|
|
|
wxString symbol;
|
2017-06-26 07:53:57 +00:00
|
|
|
|
2017-10-17 08:18:54 +00:00
|
|
|
ECOORD x;
|
|
|
|
ECOORD y;
|
2017-06-26 07:53:57 +00:00
|
|
|
|
|
|
|
opt_int addlevel;
|
|
|
|
opt_int swaplevel;
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MUST,
|
|
|
|
CAN,
|
|
|
|
NEXT,
|
|
|
|
REQUEST,
|
|
|
|
ALWAYS
|
|
|
|
};
|
|
|
|
|
|
|
|
EGATE( wxXmlNode* aGate );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct ECONNECT
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* <!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
|
|
|
wxString gate;
|
|
|
|
wxString pin;
|
|
|
|
wxString pad;
|
2017-11-01 09:20:13 +00:00
|
|
|
//int contactroute; // TODO
|
2017-06-26 07:53:57 +00:00
|
|
|
|
|
|
|
ECONNECT( wxXmlNode* aConnect );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-10-03 10:30:23 +00:00
|
|
|
struct EDEVICE
|
2017-06-26 07:53:57 +00:00
|
|
|
{
|
|
|
|
/*
|
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
|
|
|
wxString name;
|
|
|
|
opt_wxString package;
|
2017-06-26 07:53:57 +00:00
|
|
|
|
|
|
|
std::vector<ECONNECT> connects;
|
|
|
|
|
|
|
|
EDEVICE( wxXmlNode* aDevice );
|
2017-10-03 10:30:23 +00:00
|
|
|
};
|
|
|
|
|
2017-06-26 07:53:57 +00:00
|
|
|
|
2017-10-03 10:23:52 +00:00
|
|
|
struct EDEVICE_SET
|
2017-06-26 07:53:57 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
<!ELEMENT deviceset (description?, gates, devices)>
|
|
|
|
<!ATTLIST deviceset
|
|
|
|
name %String; #REQUIRED
|
|
|
|
prefix %String; ""
|
|
|
|
uservalue %Bool; "no"
|
|
|
|
>
|
|
|
|
*/
|
|
|
|
|
2017-12-14 09:37:32 +00:00
|
|
|
wxString name;
|
|
|
|
opt_wxString prefix;
|
2017-06-26 07:53:57 +00:00
|
|
|
opt_bool uservalue;
|
2017-06-30 01:52:05 +00:00
|
|
|
//std::vector<EDEVICE> devices;
|
|
|
|
//std::vector<EGATE> gates;
|
2017-06-26 07:53:57 +00:00
|
|
|
|
|
|
|
|
2017-10-03 10:23:52 +00:00
|
|
|
EDEVICE_SET( wxXmlNode* aDeviceSet );
|
2017-06-26 07:53:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-09-20 11:36:57 +00:00
|
|
|
struct ECLASS
|
|
|
|
{
|
|
|
|
wxString number;
|
|
|
|
wxString name;
|
|
|
|
std::map<wxString, ECOORD> clearanceMap;
|
|
|
|
|
|
|
|
ECLASS( wxXmlNode* aClass );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-04-07 11:40:34 +00:00
|
|
|
#endif // _EAGLE_PARSER_H_
|