Formatting.

This commit is contained in:
Jeff Young 2021-09-22 12:19:29 +01:00
parent d11c10252d
commit 5eb6b488f3
5 changed files with 78 additions and 43 deletions

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -71,9 +72,13 @@ bool Get2DPositionAndRotation( const SEXPR::SEXPR* data, DOUBLET& aPosition, dou
double x;
if( child->IsDouble() )
{
x = child->GetDouble();
}
else if( child->IsInteger() )
{
x = (double) child->GetInteger();
}
else
{
std::ostringstream ostr;
@ -86,9 +91,13 @@ bool Get2DPositionAndRotation( const SEXPR::SEXPR* data, DOUBLET& aPosition, dou
double y;
if( child->IsDouble() )
{
y = child->GetDouble();
}
else if( child->IsInteger() )
{
y = (double) child->GetInteger();
}
else
{
std::ostringstream ostr;
@ -107,9 +116,13 @@ bool Get2DPositionAndRotation( const SEXPR::SEXPR* data, DOUBLET& aPosition, dou
double angle = 0.0;
if( child->IsDouble() )
{
angle = child->GetDouble();
}
else if( child->IsInteger() )
{
angle = (double) child->GetInteger();
}
else
{
std::ostringstream ostr;
@ -147,9 +160,13 @@ bool Get2DCoordinate( const SEXPR::SEXPR* data, DOUBLET& aCoordinate )
double x;
if( child->IsDouble() )
{
x = child->GetDouble();
}
else if( child->IsInteger() )
{
x = (double) child->GetInteger();
}
else
{
std::ostringstream ostr;
@ -162,9 +179,13 @@ bool Get2DCoordinate( const SEXPR::SEXPR* data, DOUBLET& aCoordinate )
double y;
if( child->IsDouble() )
{
y = child->GetDouble();
}
else if( child->IsInteger() )
{
y = (double) child->GetInteger();
}
else
{
std::ostringstream ostr;
@ -265,18 +286,13 @@ OPT<std::string> GetLayerName( const SEXPR::SEXPR& aLayerElem )
if( aLayerElem.GetNumberOfChildren() == 2 )
{
const auto& layerChild = *aLayerElem.GetChild( 1 );
const SEXPR* layerChild = *aLayerElem.GetChild( 1 );
// The layer child can be quoted (string) or unquoted (symbol)
// depending on PCB version.
// The layer child can be quoted (string) or unquoted (symbol) depending on PCB version.
if( layerChild.IsString() )
{
layer = layerChild.GetString();
}
else if( layerChild.IsSymbol() )
{
layer = layerChild.GetSymbol();
}
}
return layer;

View File

@ -52,6 +52,7 @@ enum CURVE_TYPE
CURVE_BEZIER
};
/*
* Layers of importance to MCAD export:
* - LAYER_TOP: specifies that a footprint is on the top of the PCB
@ -66,17 +67,27 @@ enum LAYERS
LAYER_EDGE // edge data
};
struct DOUBLET
{
double x;
double y;
DOUBLET() : x( 0.0 ), y( 0.0 ) { return; }
DOUBLET( double aX, double aY ) : x( aX ), y( aY ) { return; }
DOUBLET() :
x( 0.0 ),
y( 0.0 )
{ }
DOUBLET( double aX, double aY ) :
x( aX ),
y( aY )
{ }
};
std::ostream& operator<<( std::ostream& aStream, const DOUBLET& aDoublet );
struct TRIPLET
{
double x;
@ -88,12 +99,23 @@ struct TRIPLET
double angle;
};
TRIPLET() : x( 0.0 ), y( 0.0 ), z( 0.0 ) { return; }
TRIPLET( double aX, double aY, double aZ ) : x( aX ), y( aY ), z( aZ ) { return; }
TRIPLET() :
x( 0.0 ),
y( 0.0 ),
z( 0.0 )
{ }
TRIPLET( double aX, double aY, double aZ ) :
x( aX ),
y( aY ),
z( aZ )
{ }
};
std::ostream& operator<<( std::ostream& aStream, const TRIPLET& aTriplet );
bool Get2DPositionAndRotation( const SEXPR::SEXPR* data, DOUBLET& aPosition, double& aRotation );
bool Get2DCoordinate( const SEXPR::SEXPR* data, DOUBLET& aCoordinate );
bool Get3DCoordinate( const SEXPR::SEXPR* data, TRIPLET& aCoordinate );

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -160,9 +161,8 @@ bool KICADPAD::parseDrill( const SEXPR::SEXPR* aDrill )
{
child = aDrill->GetChild( i );
// NOTE: the Offset of the copper pad is stored
// in the drill string but since the copper is not
// needed in the MCAD model the Offset is simply ignored.
// NOTE: the Offset of the copper pad is stored in the drill string but since the copper
// is not needed in the MCAD model the offset is simply ignored.
if( !child->IsList() )
{
double y;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -217,8 +217,7 @@ bool KICADPCB::parseGeneral( SEXPR::SEXPR* data )
return false;
}
// at the moment only the thickness is of interest in
// the general section
// at the moment only the thickness is of interest in the general section
if( child->GetChild( 0 )->GetSymbol() != "thickness" )
continue;
@ -286,21 +285,20 @@ bool KICADPCB::parseSetup( SEXPR::SEXPR* data )
if( !child->IsList() )
{
ReportMessage( wxString::Format(
"corrupt PCB file (line %d)\n", child->GetLineNumber() ) );
ReportMessage( wxString::Format( "corrupt PCB file (line %d)\n",
child->GetLineNumber() ) );
return false;
}
// at the moment only the Grid and Drill origins are of interest in
// the setup section
// at the moment only the Grid and Drill origins are of interest in the setup section
if( child->GetChild( 0 )->GetSymbol() == "grid_origin" )
{
if( child->GetNumberOfChildren() != 3 )
{
ReportMessage( wxString::Format(
"corrupt PCB file (line %d): grid_origin has %d children "
"(expected: 3)\n",
child->GetLineNumber(), child->GetNumberOfChildren() ) );
ReportMessage( wxString::Format( "corrupt PCB file (line %d): grid_origin has "
"%d children (expected: 3)\n",
child->GetLineNumber(),
child->GetNumberOfChildren() ) );
return false;
}
@ -312,10 +310,10 @@ bool KICADPCB::parseSetup( SEXPR::SEXPR* data )
{
if( child->GetNumberOfChildren() != 3 )
{
ReportMessage( wxString::Format(
"corrupt PCB file (line %d)m: aux_axis_origin has %d children "
"(expected: 3)\n",
child->GetLineNumber(), child->GetNumberOfChildren() ) );
ReportMessage( wxString::Format( "corrupt PCB file (line %d): aux_axis_origin has"
" %d children (expected: 3)\n",
child->GetLineNumber(),
child->GetNumberOfChildren() ) );
return false;
}

View File

@ -98,24 +98,23 @@ private:
bool parseRect( SEXPR::SEXPR* data );
bool parsePolygon( SEXPR::SEXPR* data );
S3D_RESOLVER m_resolver;
wxString m_filename;
PCBMODEL* m_pcb_model;
DOUBLET m_origin;
DOUBLET m_gridOrigin;
DOUBLET m_drillOrigin;
bool m_useGridOrigin;
bool m_useDrillOrigin;
// set to TRUE if the origin was actually parsed
bool m_hasGridOrigin;
bool m_hasDrillOrigin;
private:
S3D_RESOLVER m_resolver;
wxString m_filename;
PCBMODEL* m_pcb_model;
DOUBLET m_origin;
DOUBLET m_gridOrigin;
DOUBLET m_drillOrigin;
bool m_useGridOrigin;
bool m_useDrillOrigin;
bool m_hasGridOrigin; // indicates origin found in source file
bool m_hasDrillOrigin; // indicates origin found in source file
// minimum distance between points to treat them as separate entities (mm)
double m_minDistance;
double m_minDistance;
// the names of layers in use, and the internal layer ID
std::map<std::string, int> m_layersNames;
std::map<std::string, int> m_layersNames;
// PCB parameters/entities
double m_thickness;