Added const T& to Eagle PCB import plugin methods
This commit is contained in:
parent
9cf934ef17
commit
99f65f4dbf
|
@ -43,14 +43,14 @@ using std::string;
|
||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
string Convert<string>( wxString aValue )
|
string Convert<string>( const wxString& aValue )
|
||||||
{
|
{
|
||||||
return aValue.ToStdString();
|
return aValue.ToStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
double Convert<double>( wxString aValue )
|
double Convert<double>( const wxString& aValue )
|
||||||
{
|
{
|
||||||
double value;
|
double value;
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ double Convert<double>( wxString aValue )
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
int Convert<int>( wxString aValue )
|
int Convert<int>( const wxString& aValue )
|
||||||
{
|
{
|
||||||
if( aValue.IsEmpty() )
|
if( aValue.IsEmpty() )
|
||||||
throw XML_PARSER_ERROR( "Conversion to int failed. Original value is empty." );
|
throw XML_PARSER_ERROR( "Conversion to int failed. Original value is empty." );
|
||||||
|
@ -73,7 +73,7 @@ int Convert<int>( wxString aValue )
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
bool Convert<bool>( wxString aValue )
|
bool Convert<bool>( const wxString& aValue )
|
||||||
{
|
{
|
||||||
if( aValue != "yes" && aValue != "no" )
|
if( aValue != "yes" && aValue != "no" )
|
||||||
throw XML_PARSER_ERROR( "Conversion to bool failed. Original value, '" +
|
throw XML_PARSER_ERROR( "Conversion to bool failed. Original value, '" +
|
||||||
|
@ -83,10 +83,11 @@ bool Convert<bool>( wxString aValue )
|
||||||
return aValue == "yes";
|
return aValue == "yes";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// parse an Eagle XML "rot" field. Unfortunately the DTD seems not to explain
|
/// 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"
|
/// this format very well. [S][M]R<degrees>. Examples: "R90", "MR180", "SR180"
|
||||||
template<>
|
template<>
|
||||||
EROT Convert<EROT>( wxString aRot )
|
EROT Convert<EROT>( const wxString& aRot )
|
||||||
{
|
{
|
||||||
EROT value;
|
EROT value;
|
||||||
|
|
||||||
|
@ -630,15 +631,15 @@ unsigned long timeStamp( wxXmlNode* aTree )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxPoint kicad_arc_center( wxPoint start, wxPoint end, double angle )
|
wxPoint kicad_arc_center( const wxPoint& aStart, const wxPoint& aEnd, double aAngle )
|
||||||
{
|
{
|
||||||
// Eagle give us start and end.
|
// Eagle give us start and end.
|
||||||
// S_ARC wants start to give the center, and end to give the start.
|
// S_ARC wants start to give the center, and end to give the start.
|
||||||
double dx = end.x - start.x, dy = end.y - start.y;
|
double dx = aEnd.x - aStart.x, dy = aEnd.y - aStart.y;
|
||||||
wxPoint mid = (start + end) / 2;
|
wxPoint mid = ( aStart + aEnd ) / 2;
|
||||||
|
|
||||||
double dlen = sqrt( dx*dx + dy*dy );
|
double dlen = sqrt( dx * dx + dy * dy );
|
||||||
double dist = dlen / ( 2 * tan( DEG2RAD( angle ) / 2 ) );
|
double dist = dlen / ( 2 * tan( DEG2RAD( aAngle ) / 2 ) );
|
||||||
|
|
||||||
wxPoint center(
|
wxPoint center(
|
||||||
mid.x + dist * ( dy / dlen ),
|
mid.x + dist * ( dy / dlen ),
|
||||||
|
|
|
@ -159,7 +159,7 @@ public:
|
||||||
* type T is unknown.
|
* type T is unknown.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T Convert( wxString aValue )
|
T Convert( const wxString& aValue )
|
||||||
{
|
{
|
||||||
throw XML_PARSER_ERROR( "Conversion failed. Unknown type." );
|
throw XML_PARSER_ERROR( "Conversion failed. Unknown type." );
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ public:
|
||||||
* aData is empty, the attribute is understood as unavailable; otherwise, the
|
* aData is empty, the attribute is understood as unavailable; otherwise, the
|
||||||
* conversion to T is tried.
|
* conversion to T is tried.
|
||||||
*/
|
*/
|
||||||
OPTIONAL_XML_ATTRIBUTE( wxString aData )
|
OPTIONAL_XML_ATTRIBUTE( const wxString& aData )
|
||||||
{
|
{
|
||||||
m_isAvailable = !aData.IsEmpty();
|
m_isAvailable = !aData.IsEmpty();
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ public:
|
||||||
* @param aData is a wxString that should be converted to T. If the string is empty, the
|
* @param aData is a wxString that should be converted to T. If the string is empty, the
|
||||||
* attribute is set to unavailable.
|
* attribute is set to unavailable.
|
||||||
*/
|
*/
|
||||||
OPTIONAL_XML_ATTRIBUTE<T>& operator =( wxString aData )
|
OPTIONAL_XML_ATTRIBUTE<T>& operator =( const wxString& aData )
|
||||||
{
|
{
|
||||||
m_isAvailable = !aData.IsEmpty();
|
m_isAvailable = !aData.IsEmpty();
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ public:
|
||||||
* tries to convert a string to the base type.
|
* tries to convert a string to the base type.
|
||||||
* @param aString is the string that will be converted to the base type.
|
* @param aString is the string that will be converted to the base type.
|
||||||
*/
|
*/
|
||||||
void Set( wxString aString )
|
void Set( const wxString& aString )
|
||||||
{
|
{
|
||||||
m_data = Convert<T>( aString );
|
m_data = Convert<T>( aString );
|
||||||
}
|
}
|
||||||
|
@ -685,6 +685,6 @@ string makeKey( const string& aFirst, const string& aSecond );
|
||||||
unsigned long timeStamp( wxXmlNode* aTree );
|
unsigned long timeStamp( wxXmlNode* aTree );
|
||||||
|
|
||||||
/// Convert an Eagle curve end to a KiCad center for S_ARC
|
/// Convert an Eagle curve end to a KiCad center for S_ARC
|
||||||
wxPoint kicad_arc_center( wxPoint start, wxPoint end, double angle );
|
wxPoint kicad_arc_center( const wxPoint& aStart, const wxPoint& aEnd, double aAngle );
|
||||||
|
|
||||||
#endif // _EAGLE_PARSER_H_
|
#endif // _EAGLE_PARSER_H_
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue