Make PCAD import case-insensitive

According to the PCAD specification, all tags are case insensitive.
Most exporters honor the defaults but there is always an outlier or two

Fixes https://gitlab.com/kicad/code/kicad/issues/11652

(cherry picked from commit 35b79c2ec9)
This commit is contained in:
Seth Hillbrand 2022-05-27 10:08:27 -07:00
parent c38da73151
commit 2d092437f4
4 changed files with 47 additions and 55 deletions

View File

@ -304,21 +304,21 @@ TTEXT_JUSTIFY GetJustifyIdentificator( const wxString& aJustify )
{
TTEXT_JUSTIFY id;
if( aJustify == wxT( "LowerCenter" ) )
if( aJustify.IsSameAs( wxT( "LowerCenter" ), false ) )
id = LowerCenter;
else if( aJustify == wxT( "LowerRight" ) )
else if( aJustify.IsSameAs( wxT( "LowerRight" ), false ) )
id = LowerRight;
else if( aJustify == wxT( "UpperLeft" ) )
else if( aJustify.IsSameAs( wxT( "UpperLeft" ), false ) )
id = UpperLeft;
else if( aJustify == wxT( "UpperCenter" ) )
else if( aJustify.IsSameAs( wxT( "UpperCenter" ), false ) )
id = UpperCenter;
else if( aJustify == wxT( "UpperRight" ) )
else if( aJustify.IsSameAs( wxT( "UpperRight" ), false ) )
id = UpperRight;
else if( aJustify == wxT( "Left" ) )
else if( aJustify.IsSameAs( wxT( "Left" ), false ) )
id = Left;
else if( aJustify == wxT( "Center" ) )
else if( aJustify.IsSameAs( wxT( "Center" ), false ) )
id = Center;
else if( aJustify == wxT( "Right" ) )
else if( aJustify.IsSameAs( wxT( "Right" ), false ) )
id = Right;
else
id = LowerLeft;
@ -354,7 +354,7 @@ void SetTextParameters( XNODE* aNode, TTEXTVALUE* aTextValue,
str = FindNodeGetContent( aNode, wxT( "isVisible" ) );
if( str == wxT( "True" ) )
if( str.IsSameAs( wxT( "True" ), false ) )
aTextValue->textIsVisible = 1;
else
aTextValue->textIsVisible = 0;
@ -364,7 +364,7 @@ void SetTextParameters( XNODE* aNode, TTEXTVALUE* aTextValue,
str = FindNodeGetContent( aNode, wxT( "isFlipped" ) );
if( str == wxT( "True" ) )
if( str.IsSameAs( wxT( "True" ), false ) )
aTextValue->mirror = 1;
else
aTextValue->mirror = 0;
@ -408,13 +408,13 @@ void SetFontProperty( XNODE* aNode, TTEXTVALUE* aTextValue, const wxString& aDef
wxString fontType;
propValue = FindNodeGetContent( aNode, wxT( "textStyleDisplayTType" ) );
aTextValue->isTrueType = ( propValue == wxT( "True" ) );
aTextValue->isTrueType = ( propValue.IsSameAs( wxT( "True" ), false ) );
aNode = FindNode( aNode, wxT( "font" ) );
fontType = FindNodeGetContent( aNode, wxT( "fontType" ) );
if( ( aTextValue->isTrueType && ( fontType != wxT( "TrueType" ) ) ) ||
( !aTextValue->isTrueType && ( fontType != wxT( "Stroke" ) ) ) )
if( ( aTextValue->isTrueType && !fontType.IsSameAs( wxT( "TrueType" ), false ) ) ||
( !aTextValue->isTrueType && !fontType.IsSameAs( wxT( "Stroke" ), false ) ) )
aNode = aNode->GetNext();
if( aNode )
@ -422,7 +422,7 @@ void SetFontProperty( XNODE* aNode, TTEXTVALUE* aTextValue, const wxString& aDef
if( aTextValue->isTrueType )
{
propValue = FindNodeGetContent( aNode, wxT( "fontItalic" ) );
aTextValue->isItalic = ( propValue == wxT( "True" ) );
aTextValue->isItalic = propValue.IsSameAs( wxT( "True" ), false );
propValue = FindNodeGetContent( aNode, wxT( "fontWeight" ) );
@ -562,7 +562,7 @@ XNODE* FindNode( XNODE* aChild, const wxString& aTag )
while( aChild )
{
if( aChild->GetName() == aTag )
if( aChild->GetName().IsSameAs( aTag, false ) )
return aChild;
aChild = aChild->GetNext();

View File

@ -148,7 +148,7 @@ XNODE* PCB::FindCompDefName( XNODE* aNode, const wxString& aName ) const
while( lNode )
{
if( lNode->GetName() == wxT( "compDef" ) )
if( lNode->GetName().IsSameAs( wxT( "compDef" ), false ) )
{
lNode->GetAttribute( wxT( "Name" ), &propValue );
@ -190,7 +190,7 @@ void PCB::SetTextProperty( XNODE* aNode, TTEXTVALUE* aTextValue, const wxString&
while( tNode )
{
if( tNode->GetName() == wxT( "patternGraphicsRef" ) )
if( tNode->GetName().IsSameAs( wxT( "patternGraphicsRef" ), false ) )
{
if( FindNode( tNode, wxT( "patternGraphicsNameRef" ) ) )
{
@ -252,7 +252,7 @@ void PCB::DoPCBComponents( XNODE* aNode, wxXmlDocument* aXmlDoc, const wxString&
{
fp = nullptr;
if( lNode->GetName() == wxT( "pattern" ) )
if( lNode->GetName().IsSameAs( wxT( "pattern" ), false ) )
{
FindNode( lNode, wxT( "patternRef" ) )->GetAttribute( wxT( "Name" ),
&cn );
@ -309,7 +309,7 @@ void PCB::DoPCBComponents( XNODE* aNode, wxXmlDocument* aXmlDoc, const wxString&
str = FindNodeGetContent( lNode, wxT( "isFlipped" ) );
if( str == wxT( "True" ) )
if( str.IsSameAs( wxT( "True" ), false ) )
fp->m_Mirror = 1;
tNode = aNode;
@ -370,7 +370,7 @@ void PCB::DoPCBComponents( XNODE* aNode, wxXmlDocument* aXmlDoc, const wxString&
while( mNode )
{
if( mNode->GetName() == wxT( "padNum" ) )
if( mNode->GetName().IsSameAs( wxT( "padNum" ), false ) )
{
str = mNode->GetNodeContent();
mNode = mNode->GetNext();
@ -398,19 +398,19 @@ void PCB::DoPCBComponents( XNODE* aNode, wxXmlDocument* aXmlDoc, const wxString&
m_PcbComponents.Add( fp );
}
}
else if( lNode->GetName() == wxT( "pad" ) )
else if( lNode->GetName().IsSameAs( wxT( "pad" ), false ) )
{
pad = new PCB_PAD( this, m_board );
pad->Parse( lNode, m_DefaultMeasurementUnit, aActualConversion );
m_PcbComponents.Add( pad );
}
else if( lNode->GetName() == wxT( "via" ) )
else if( lNode->GetName().IsSameAs( wxT( "via" ), false ) )
{
via = new PCB_VIA( this, m_board );
via->Parse( lNode, m_DefaultMeasurementUnit, aActualConversion );
m_PcbComponents.Add( via );
}
else if( lNode->GetName() == wxT( "polyKeepOut" ) )
else if( lNode->GetName().IsSameAs( wxT( "polyKeepOut" ), false ) )
{
keepOut = new PCB_KEEPOUT( m_callbacks, m_board, 0 );
@ -545,13 +545,13 @@ void PCB::MapLayer( XNODE* aNode )
{
layerType = FindNode( aNode, wxT( "layerType" ) )->GetNodeContent().Trim( false );
if( layerType == wxT( "NonSignal" ) )
if( layerType.IsSameAs( wxT( "NonSignal" ), false ) )
newlayer.layerType = LAYER_TYPE_NONSIGNAL;
if( layerType == wxT( "Signal" ) )
if( layerType.IsSameAs( wxT( "Signal" ), false ) )
newlayer.layerType = LAYER_TYPE_SIGNAL;
if( layerType == wxT( "Plane" ) )
if( layerType.IsSameAs( wxT( "Plane" ), false ) )
newlayer.layerType = LAYER_TYPE_PLANE;
}
@ -578,15 +578,6 @@ int PCB::FindOutlinePoint( const VERTICES_ARRAY* aOutline, wxRealPoint aPoint )
}
/*int cmpFunc( wxRealPoint **first, wxRealPoint **second )
{
return sqrt( pow( (double) aPointA.x - (double) aPointB.x, 2 ) +
pow( (double) aPointA.y - (double) aPointB.y, 2 ) );
return 0;
}*/
double PCB::GetDistance( const wxRealPoint* aPoint1, const wxRealPoint* aPoint2 ) const
{
return sqrt( ( aPoint1->x - aPoint2->x ) * ( aPoint1->x - aPoint2->x ) +
@ -611,7 +602,7 @@ void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConver
while( iNode )
{
// objects
if( iNode->GetName() == wxT( "layerContents" ) )
if( iNode->GetName().IsSameAs( wxT( "layerContents" ), false ) )
{
if( FindNode( iNode, wxT( "layerNumRef" ) ) )
FindNode( iNode, wxT( "layerNumRef" ) )->GetNodeContent().ToLong( &PCadLayer );
@ -622,7 +613,7 @@ void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConver
while( lNode )
{
if( lNode->GetName() == wxT( "line" ) )
if( lNode->GetName().IsSameAs( wxT( "line" ), false ) )
{
pNode = FindNode( lNode, wxT( "pt" ) );
@ -747,14 +738,15 @@ void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc,
while( aNode )
{
if( aNode->GetName() == wxT( "layerDef" ) )
if( aNode->GetName().IsSameAs( wxT( "layerDef" ), false ) )
{
if( FindNode( aNode, wxT( "layerType" ) ) )
{
layerType = FindNode( aNode,
wxT( "layerType" ) )->GetNodeContent().Trim( false );
layerType = FindNode( aNode, wxT( "layerType" ) )->GetNodeContent().Trim(
false );
if( layerType == wxT( "Signal" ) || layerType == wxT( "Plane" ) )
if( layerType.IsSameAs( wxT( "Signal" ), false )
|| layerType.IsSameAs( wxT( "Plane" ), false ) )
{
aNode->GetAttribute( wxT( "Name" ), &layerName );
layerName = layerName.MakeUpper();
@ -779,7 +771,7 @@ void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc,
while( aNode )
{
if( aNode->GetName() == wxT( "layerDef" ) )
if( aNode->GetName().IsSameAs( wxT( "layerDef" ), false ) )
MapLayer( aNode );
aNode = aNode->GetNext();
@ -822,11 +814,11 @@ void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc,
while( aNode )
{
// Components/footprints
if( aNode->GetName() == wxT( "multiLayer" ) )
if( aNode->GetName().IsSameAs( wxT( "multiLayer" ), false ) )
DoPCBComponents( aNode, aXmlDoc, aActualConversion, aStatusBar );
// objects
if( aNode->GetName() == wxT( "layerContents" ) )
if( aNode->GetName().IsSameAs( wxT( "layerContents" ), false ) )
DoLayerContentsObjects( aNode, nullptr, &m_PcbComponents, aStatusBar,
m_DefaultMeasurementUnit, aActualConversion );
@ -924,7 +916,7 @@ void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc,
{
// aStatusBar->SetStatusText( wxT( "Processing COMPONENTS " ) );
if( aNode->GetName() == wxT( "compDef" ) )
if( aNode->GetName().IsSameAs( wxT( "compDef" ), false ) )
{
footprint = new PCB_FOOTPRINT( this, m_board );
footprint->Parse( aNode, aStatusBar, m_DefaultMeasurementUnit,

View File

@ -154,14 +154,14 @@ void PCB_PAD::Parse( XNODE* aNode, const wxString& aDefaultUnits,
if( cNode )
SetWidth( cNode->GetNodeContent(), aDefaultUnits, &m_Hole, aActualConversion );
if( FindNodeGetContent( lNode, wxT( "isHolePlated" ) ) == wxT( "False" ) )
if( FindNodeGetContent( lNode, wxT( "isHolePlated" ) ).IsSameAs( wxT( "False" ), false ) )
m_IsHolePlated = false;
cNode = FindNode( lNode, wxT( "padShape" ) );
while( cNode )
{
if( cNode->GetName() == wxT( "padShape" ) )
if( cNode->GetName().IsSameAs( wxT( "padShape" ), false ) )
{
// we support only Pads on specific layers......
// we do not support pads on "Plane", "NonSignal" , "Signal" ... layerr
@ -215,7 +215,7 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
// Mounting Hole: Solder Mask Margin from Top Layer Width size.
// Used the default zone clearance (simplify)
if( m_Shapes.GetCount() && m_Shapes[0]->m_Shape == wxT( "MtHole" ) )
if( m_Shapes.GetCount() && m_Shapes[0]->m_Shape.IsSameAs( wxT( "MtHole" ), false ) )
{
int sm_margin = ( m_Shapes[0]->m_Width - m_Hole ) / 2;
pad->SetLocalSolderMaskMargin( sm_margin );
@ -265,24 +265,24 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
pad->SetNumber( m_name.text );
if( padShapeName == wxT( "Oval" )
|| padShapeName == wxT( "Ellipse" )
|| padShapeName == wxT( "MtHole" ) )
if( padShapeName.IsSameAs( wxT( "Oval" ), false )
|| padShapeName.IsSameAs( wxT( "Ellipse" ), false )
|| padShapeName.IsSameAs( wxT( "MtHole" ), false ) )
{
if( width != height )
pad->SetShape( PAD_SHAPE::OVAL );
else
pad->SetShape( PAD_SHAPE::CIRCLE );
}
else if( padShapeName == wxT( "Rect" ) )
else if( padShapeName.IsSameAs( wxT( "Rect" ), false ) )
{
pad->SetShape( PAD_SHAPE::RECT );
}
else if( padShapeName == wxT( "RndRect" ) )
else if( padShapeName.IsSameAs( wxT( "RndRect" ), false ) )
{
pad->SetShape( PAD_SHAPE::ROUNDRECT );
}
else if( padShapeName == wxT( "Polygon" ) )
else if( padShapeName.IsSameAs( wxT( "Polygon" ), false ) )
{
pad->SetShape( PAD_SHAPE::RECT ); // approximation
}

View File

@ -82,7 +82,7 @@ void PCB_TEXT::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
str = FindNodeGetContent( aNode, wxT( "isFlipped" ) );
if( str == wxT( "True" ) )
if( str.IsSameAs( wxT( "True" ), false ) )
m_name.mirror = 1;
lNode = FindNode( aNode, wxT( "textStyleRef" ) );