7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-03-30 06:46:34 +00:00

Common folder housekeeping part 2.

This commit is contained in:
Wayne Stambaugh 2025-01-13 13:05:29 -05:00
parent 7bf0d36057
commit f161d94521
72 changed files with 672 additions and 445 deletions

View File

@ -161,15 +161,6 @@ static struct hotkey_name_descr hotkeyNameList[] =
#define MODIFIER_SHIFT wxT( "Shift+" )
/**
* Return the key name from the key code.
*
* Only some wxWidgets key values are handled for function key ( see hotkeyNameList[] )
*
* @param aKeycode key code (ASCII value, or wxWidgets value for function keys).
* @param aIsFound a pointer to a bool to return true if found, or false. an be nullptr default).
* @return the key name in a wxString.
*/
wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound )
{
wxString keyname, modifier, fullkeyname;
@ -229,12 +220,6 @@ wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound )
}
/**
* @param aText the base text on which to append the hotkey.
* @param aHotKey the hotkey keycode.
* @param aStyle IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys).
* IS_COMMENT to add <spaces><(keyname)> mainly in tool tips.
*/
wxString AddHotkeyName( const wxString& aText, int aHotKey, HOTKEY_ACTION_TYPE aStyle )
{
wxString msg = aText;
@ -273,9 +258,6 @@ wxString AddHotkeyName( const wxString& aText, int aHotKey, HOTKEY_ACTION_TYPE a
}
/**
* Return the key code from its user-friendly key name (ie: "Ctrl+M").
*/
int KeyCodeFromKeyName( const wxString& keyname )
{
int ii, keycode = KEY_NON_FOUND;
@ -339,9 +321,6 @@ int KeyCodeFromKeyName( const wxString& keyname )
}
/*
* Displays the hotkeys registered with the given tool manager.
*/
void DisplayHotkeyList( EDA_BASE_FRAME* aParent )
{
DIALOG_LIST_HOTKEYS dlg( aParent );
@ -399,11 +378,13 @@ void ReadHotKeyConfigIntoActions( const wxString& aFileName, std::vector<TOOL_AC
// Set each tool action hotkey to the config file hotkey if present
for( TOOL_ACTION* action : aActions )
{
if( hotkeys.find( action->GetName() ) != hotkeys.end() )
{
std::pair<int, int> keys = hotkeys[action->GetName()];
action->SetHotKey( keys.first, keys.second );
}
}
}
@ -420,7 +401,8 @@ int WriteHotKeyConfig( const std::vector<TOOL_ACTION*>& aActions )
// Overlay the current app's hotkey definitions onto the map
for( const TOOL_ACTION* action : aActions )
hotkeys[ action->GetName() ] = std::pair<int, int>( action->GetHotKey(), action->GetHotKeyAlt() );
hotkeys[ action->GetName() ] = std::pair<int, int>( action->GetHotKey(),
action->GetHotKeyAlt() );
// Write entire hotkey set
wxFFileOutputStream outStream( fn.GetFullPath() );

View File

@ -420,17 +420,7 @@ bool HTTP_LIB_CONNECTION::boolFromString( const std::any& aVal, bool aDefaultVal
return aDefaultValue;
}
/*
* HTTP response status codes indicate whether a specific HTTP request has been successfully completed.
* Responses are grouped in five classes:
* Informational responses (100 ? 199)
* Successful responses (200 ? 299)
* Redirection messages (300 ? 399)
* Client error responses (400 ? 499)
* Server error responses (500 ? 599)
*
* see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
*/
wxString HTTP_LIB_CONNECTION::httpErrorCodeDescription( uint16_t aHttpCode )
{
auto codeDescription =
@ -450,7 +440,7 @@ wxString HTTP_LIB_CONNECTION::httpErrorCodeDescription( uint16_t aHttpCode )
case 205: return wxS( "Reset Content" );
case 206: return wxS( "Partial Content" );
case 207: return wxS( "Multi-Status" );
case 208: return wxS( "Already Reporte" );
case 208: return wxS( "Already Reported" );
case 226: return wxS( "IM Used" );
case 300: return wxS( "Multiple Choices" );
@ -482,7 +472,7 @@ wxString HTTP_LIB_CONNECTION::httpErrorCodeDescription( uint16_t aHttpCode )
case 417: return wxS( "Expectation Failed" );
case 418: return wxS( "I'm a teapot" );
case 421: return wxS( "Misdirected Request" );
case 422: return wxS( "Unprocessable Conten" );
case 422: return wxS( "Unprocessable Content" );
case 423: return wxS( "Locked" );
case 424: return wxS( "Failed Dependency" );
case 425: return wxS( "Too Early (Experimental)" );
@ -499,8 +489,8 @@ wxString HTTP_LIB_CONNECTION::httpErrorCodeDescription( uint16_t aHttpCode )
case 504: return wxS( "Gateway Timeout" );
case 505: return wxS( "HTTP Version Not Supported" );
case 506: return wxS( "Variant Also Negotiates" );
case 507: return wxS( "Insufficient Storag" );
case 508: return wxS( "Loop Detecte" );
case 507: return wxS( "Insufficient Storage" );
case 508: return wxS( "Loop Detected" );
case 510: return wxS( "Not Extended" );
case 511: return wxS( "Network Authentication Required" );
default: return wxS( "Unknown" );

View File

@ -76,7 +76,7 @@
* 6. Blocks are virtual groups, blocks must be placed by a INSERT entity
* 7. Blocks may be repeated multiple times
* 8. There is no sane way to make text look perfect like the original CAD.
* DXF simply does mpt secifying text/font enough to make it portable.
* DXF simply does mpt specifying text/font enough to make it portable.
* We however make do try to get it somewhat close/visually appealing.
* 9. We silently drop the z coordinate on 3d polylines
*/
@ -464,7 +464,8 @@ void DXF_IMPORT_PLUGIN::addVertex( const DL_VertexData& aData )
if( std::abs( m_curr_entity.m_BulgeVertex ) < MIN_BULGE )
insertLine( m_curr_entity.m_LastCoordinate, seg_end, lineWidth );
else
insertArc( m_curr_entity.m_LastCoordinate, seg_end, m_curr_entity.m_BulgeVertex, lineWidth );
insertArc( m_curr_entity.m_LastCoordinate, seg_end, m_curr_entity.m_BulgeVertex,
lineWidth );
m_curr_entity.m_LastCoordinate = seg_end;
m_curr_entity.m_BulgeVertex = vertex->bulge;
@ -691,9 +692,10 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
{
MATRIX3x3D arbAxis = getArbitraryAxis( getExtrusion() );
VECTOR3D refPointCoords = ocsToWcs( arbAxis, VECTOR3D( aData.ipx, aData.ipy, aData.ipz ) );
VECTOR3D secPointCoords = ocsToWcs( arbAxis, VECTOR3D( std::isnan( aData.apx ) ? 0 : aData.apx,
std::isnan( aData.apy ) ? 0 : aData.apy,
std::isnan( aData.apz ) ? 0 : aData.apz ) );
VECTOR3D secPointCoords =
ocsToWcs( arbAxis, VECTOR3D( std::isnan( aData.apx ) ? 0 : aData.apx,
std::isnan( aData.apy ) ? 0 : aData.apy,
std::isnan( aData.apz ) ? 0 : aData.apz ) );
VECTOR2D refPoint( mapX( refPointCoords.x ), mapY( refPointCoords.y ) );
VECTOR2D secPoint( mapX( secPointCoords.x ), mapY( secPointCoords.y ) );
@ -713,6 +715,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
DXF_IMPORT_STYLE* style = getImportStyle( aData.style.c_str() );
double textHeight = mapDim( aData.height );
// The 0.9 factor gives a better height/width base ratio with our font
double charWidth = textHeight * 0.9;
@ -720,12 +723,12 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
charWidth *= style->m_widthFactor;
double textWidth = charWidth * text.length(); // Rough approximation
double textThickness = textHeight/8.0; // Use a reasonable line thickness for this text
double textThickness = textHeight / 8.0; // Use a reasonable line thickness for this text
VECTOR2D bottomLeft(0.0, 0.0);
VECTOR2D bottomRight(0.0, 0.0);
VECTOR2D topLeft(0.0, 0.0);
VECTOR2D topRight(0.0, 0.0);
VECTOR2D bottomLeft( 0.0, 0.0 );
VECTOR2D bottomRight( 0.0, 0.0 );
VECTOR2D topLeft( 0.0, 0.0 );
VECTOR2D topRight( 0.0, 0.0 );
GR_TEXT_H_ALIGN_T hJustify = GR_TEXT_H_ALIGN_LEFT;
GR_TEXT_V_ALIGN_T vJustify = GR_TEXT_V_ALIGN_BOTTOM;
@ -804,6 +807,7 @@ void DXF_IMPORT_PLUGIN::addText( const DL_TextData& aData )
// dxf_lib imports text angle in radians (although there are no comment about that.
// So, for the moment, convert this angle to degrees
double angle_degree = aData.angle * 180 / M_PI;
// We also need the angle in radians. so convert angle_degree to radians
// regardless the aData.angle unit
double angleInRads = angle_degree * M_PI / 180.0;
@ -957,6 +961,7 @@ void DXF_IMPORT_PLUGIN::addMText( const DL_MTextData& aData )
// dxf_lib imports text angle in radians (although there are no comment about that.
// So, for the moment, convert this angle to degrees
double angle_degree = aData.angle * 180/M_PI;
// We also need the angle in radians. so convert angle_degree to radians
// regardless the aData.angle unit
double angleInRads = angle_degree * M_PI / 180.0;
@ -1032,7 +1037,6 @@ double DXF_IMPORT_PLUGIN::getCurrentUnitScale()
}
void DXF_IMPORT_PLUGIN::setVariableInt( const std::string& key, int value, int code )
{
// Called for every int variable in the DXF file (e.g. "$INSUNITS").
@ -1334,6 +1338,7 @@ wxString DXF_IMPORT_PLUGIN::toNativeString( const wxString& aData )
// degree:
regexp.Compile( wxT( "%%[dD]" ) );
regexp.Replace( &res, wxChar( 0x00B0 ) );
// plus/minus
regexp.Compile( wxT( "%%[pP]" ) );
regexp.Replace( &res, wxChar( 0x00B1 ) );
@ -1410,10 +1415,13 @@ void DXF_IMPORT_PLUGIN::insertArc( const VECTOR2D& aSegStart, const VECTOR2D& aS
// reflect the Y values to put everything in a RHCS
VECTOR2D sp( aSegStart.x, -aSegStart.y );
VECTOR2D ep( aSegEnd.x, -aSegEnd.y );
// angle from end->start
double offAng = atan2( ep.y - sp.y, ep.x - sp.x );
// length of subtended segment = 1/2 distance between the 2 points
double d = 0.5 * sqrt( (sp.x - ep.x) * (sp.x - ep.x) + (sp.y - ep.y) * (sp.y - ep.y) );
double d = 0.5 * sqrt( ( sp.x - ep.x ) * ( sp.x - ep.x ) + ( sp.y - ep.y ) * ( sp.y - ep.y ) );
// midpoint of the subtended segment
double xm = ( sp.x + ep.x ) * 0.5;
double ym = ( sp.y + ep.y ) * 0.5;
@ -1477,11 +1485,11 @@ void DXF_IMPORT_PLUGIN::insertArc( const VECTOR2D& aSegStart, const VECTOR2D& aS
void DXF_IMPORT_PLUGIN::insertSpline( double aWidth )
{
#if 0 // Debug only
wxLogMessage("spl deg %d kn %d ctr %d fit %d",
m_curr_entity.m_SplineDegree,
m_curr_entity.m_SplineKnotsList.size(),
m_curr_entity.m_SplineControlPointList.size(),
m_curr_entity.m_SplineFitPointList.size() );
wxLogMessage( "spl deg %d kn %d ctr %d fit %d",
m_curr_entity.m_SplineDegree,
m_curr_entity.m_SplineKnotsList.size(),
m_curr_entity.m_SplineControlPointList.size(),
m_curr_entity.m_SplineFitPointList.size() );
#endif
unsigned imax = m_curr_entity.m_SplineControlPointList.size();

View File

@ -335,13 +335,13 @@ private:
MATRIX3x3D getArbitraryAxis( DL_Extrusion* aData );
/**
* Converts a given world coordinate point to object coordinate using the given arbitrary
* Convert a given world coordinate point to object coordinate using the given arbitrary
* axis vectors.
*/
VECTOR3D wcsToOcs( const MATRIX3x3D& arbitraryAxis, VECTOR3D point );
/**
* Converts a given object coordinate point to world coordinate using the given arbitrary
* Convert a given object coordinate point to world coordinate using the given arbitrary
* axis vectors.
*/
VECTOR3D ocsToWcs( const MATRIX3x3D& arbitraryAxis, VECTOR3D point );
@ -436,7 +436,7 @@ private:
/**
* Called for every spline.
* */
*/
virtual void addSpline( const DL_SplineData& aData ) override;
/**
@ -459,6 +459,7 @@ private:
{
ReportMsg( _( "DXF construction lines not currently supported." ) );
}
virtual void addRay( const DL_RayData& ) override
{
ReportMsg( _( "DXF construction lines not currently supported." ) );
@ -473,30 +474,37 @@ private:
{
ReportMsg( _( "DXF dimensions not currently supported." ) );
}
virtual void addDimLinear( const DL_DimensionData&, const DL_DimLinearData& ) override
{
ReportMsg( _( "DXF dimensions not currently supported." ) );
}
virtual void addDimRadial( const DL_DimensionData&, const DL_DimRadialData& ) override
{
ReportMsg( _( "DXF dimensions not currently supported." ) );
}
virtual void addDimDiametric( const DL_DimensionData&, const DL_DimDiametricData& ) override
{
ReportMsg( _( "DXF dimensions not currently supported." ) );
}
virtual void addDimAngular( const DL_DimensionData&, const DL_DimAngular2LData& ) override
{
ReportMsg( _( "DXF dimensions not currently supported." ) );
}
virtual void addDimAngular3P( const DL_DimensionData&, const DL_DimAngular3PData& ) override
{
ReportMsg( _( "DXF dimensions not currently supported." ) );
}
virtual void addDimOrdinate( const DL_DimensionData&, const DL_DimOrdinateData& ) override
{
ReportMsg( _( "DXF dimensions not currently supported." ) );
}
virtual void addLeader( const DL_LeaderData& ) override
{
ReportMsg( _( "DXF dimensions not currently supported." ) );
@ -507,6 +515,7 @@ private:
{
ReportMsg( _( "DXF hatches not currently supported." ) );
}
virtual void addHatchLoop( const DL_HatchLoopData& ) override { }
virtual void addHatchEdge( const DL_HatchEdgeData& ) override { }

View File

@ -39,23 +39,23 @@ class wxString;
class GRAPHICS_IMPORT_MGR
{
public:
///< List of handled file types.
/// List of handled file types.
enum GFX_FILE_T
{
DXF,
SVG
};
///< Vector containing all GFX_FILE_T values that can be imported.
/// Vector containing all GFX_FILE_T values that can be imported.
std::vector<GFX_FILE_T> GetImportableFileTypes() const
{
return { DXF, SVG };
}
///< Returns a plugin that handles a specific file extension.
/// Return a plugin that handles a specific file extension.
std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> GetPluginByExt( const wxString& aExtension ) const;
///< Returns a plugin instance for a specific file type.
/// Return a plugin instance for a specific file type.
std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> GetPlugin( GFX_FILE_T aType ) const;
};

View File

@ -134,7 +134,7 @@ public:
virtual void ReportMsg( const wxString& aMessage ) = 0;
protected:
///< Importer used to create objects representing the imported shapes.
/// Importer used to create objects representing the imported shapes.
GRAPHICS_IMPORTER* m_importer;
};

View File

@ -233,7 +233,7 @@ public:
m_items.clear();
}
///< Default line thickness (in mm)
/// Default line thickness (in mm).
static constexpr unsigned int DEFAULT_LINE_WIDTH_DFX = 1;
virtual void NewShape( POLY_FILL_RULE aFillRule = PF_NONZERO );
@ -313,45 +313,46 @@ public:
const IMPORTED_STROKE& aStroke ) = 0;
protected:
///< Add an item to the imported shapes list.
/// Add an item to the imported shapes list.
void addItem( std::unique_ptr<EDA_ITEM> aItem );
/*
/**
* Configure a shape as a spline or a line segment if it's degenerate.
*
* @return false if the shape is near-zero length and should be ignored.
*/
bool setupSplineOrLine( EDA_SHAPE& aShape, int aAccuracy );
///< factor to convert millimeters to Internal Units
/// Factor to convert millimeters to Internal Units.
double m_millimeterToIu;
///< Offset (in mm) for imported coordinates
/// Offset (in mm) for imported coordinates.
VECTOR2D m_offsetCoordmm;
std::vector<POLY_FILL_RULE> m_shapeFillRules;
private:
///< List of imported items
/// List of imported items.
std::list<std::unique_ptr<EDA_ITEM>> m_items;
///< Plugin used to load a file
/// Plugin used to load a file.
std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> m_plugin;
///< Total image width
/// Total image width.
double m_originalWidth;
///< Total image Height;
/// Total image Height.
double m_originalHeight;
/**
* Scale factor applied to the imported graphics.
*
* 1.0 does not change the size of imported items
* scale < 1.0 reduce the size of imported items
*/
VECTOR2D m_scale;
///< Default line thickness for the imported graphics
/// Default line thickness for the imported graphics.
double m_lineWidth;
};

View File

@ -114,18 +114,22 @@ void GRAPHICS_IMPORTER_BUFFER::ImportTo( GRAPHICS_IMPORTER& aImporter )
boundingBox.GetSize().y * aImporter.GetScale().y );
// Check that the scaled graphics fit in the KiCad numeric limits
if( boundingBox.GetSize().x * aImporter.GetMillimeterToIuFactor() > std::numeric_limits<int>::max() ||
boundingBox.GetSize().y * aImporter.GetMillimeterToIuFactor() > std::numeric_limits<int>::max() )
if( boundingBox.GetSize().x * aImporter.GetMillimeterToIuFactor()
> std::numeric_limits<int>::max()
|| boundingBox.GetSize().y * aImporter.GetMillimeterToIuFactor()
> std::numeric_limits<int>::max() )
{
double scale_factor = std::numeric_limits<int>::max() / ( aImporter.GetMillimeterToIuFactor() + 100 );
double scale_factor = std::numeric_limits<int>::max() /
( aImporter.GetMillimeterToIuFactor() + 100 );
double max_scale = std::max( scale_factor / boundingBox.GetSize().x,
scale_factor / boundingBox.GetSize().y );
aImporter.ReportMsg( wxString::Format( _( "Imported graphic is too large. Maximum scale is %f" ),
max_scale ) );
aImporter.ReportMsg( wxString::Format( _( "Imported graphic is too large. Maximum scale "
"is %f" ),
max_scale ) );
return;
}
// They haven't set the import offset, so we set it to the bounding box origin to keep the graphics
// in the KiCad drawing area
// They haven't set the import offset, so we set it to the bounding box origin to keep
// the graphics in the KiCad drawing area.
else if( aImporter.GetImportOffsetMM() == VECTOR2D( 0, 0 ) )
{
if( boundingBox.GetRight() > std::numeric_limits<int>::max()
@ -156,7 +160,8 @@ void GRAPHICS_IMPORTER_BUFFER::ImportTo( GRAPHICS_IMPORTER& aImporter )
if( max_offset_x >= std::numeric_limits<int>::max() )
{
newOffset.x -= ( max_offset_x - std::numeric_limits<int>::max() + 100.0 ) / total_scale_x;
newOffset.x -= ( max_offset_x - std::numeric_limits<int>::max() + 100.0 ) /
total_scale_x;
needsAdjustment = true;
}
else if( min_offset_x <= std::numeric_limits<int>::min() )
@ -178,7 +183,8 @@ void GRAPHICS_IMPORTER_BUFFER::ImportTo( GRAPHICS_IMPORTER& aImporter )
if( needsAdjustment )
{
aImporter.ReportMsg( wxString::Format( _( "Import offset adjusted to (%f, %f) to fit within numeric limits" ),
aImporter.ReportMsg( wxString::Format( _( "Import offset adjusted to (%f, %f) to fit "
"within numeric limits" ),
newOffset.x, newOffset.y ) );
aImporter.SetImportOffsetMM( newOffset );
}
@ -188,7 +194,8 @@ void GRAPHICS_IMPORTER_BUFFER::ImportTo( GRAPHICS_IMPORTER& aImporter )
shape->ImportTo( aImporter );
}
// converts a single SVG-style polygon (multiple outlines, hole detection based on orientation, custom fill rule) to a format that can be digested by KiCad (single outline, fractured)
// converts a single SVG-style polygon (multiple outlines, hole detection based on orientation,
// custom fill rule) to a format that can be digested by KiCad (single outline, fractured).
static void convertPolygon( std::list<std::unique_ptr<IMPORTED_SHAPE>>& aShapes,
std::vector<IMPORTED_POLYGON*>& aPaths,
GRAPHICS_IMPORTER::POLY_FILL_RULE aFillRule,
@ -200,8 +207,8 @@ static void convertPolygon( std::list<std::unique_ptr<IMPORTED_SHAPE>>& aShapes,
double maxX = std::numeric_limits<double>::min();
double maxY = maxX;
// as Clipper/SHAPE_POLY_SET uses ints we first need to upscale to a reasonably large size (in integer coordinates)
// to avoid losing accuracy
// as Clipper/SHAPE_POLY_SET uses ints we first need to upscale to a reasonably large size
// (in integer coordinates) to avoid losing accuracy.
const double convert_scale = 1000000000.0;
for( IMPORTED_POLYGON* path : aPaths )
@ -254,13 +261,15 @@ static void convertPolygon( std::list<std::unique_ptr<IMPORTED_SHAPE>>& aShapes,
}
SHAPE_POLY_SET result;
result.BuildPolysetFromOrientedPaths( upscaledPaths, aFillRule == GRAPHICS_IMPORTER::PF_EVEN_ODD );
result.BuildPolysetFromOrientedPaths( upscaledPaths,
aFillRule == GRAPHICS_IMPORTER::PF_EVEN_ODD );
result.Fracture();
for( int outl = 0; outl < result.OutlineCount(); outl++ )
{
const SHAPE_LINE_CHAIN& ro = result.COutline( outl );
std::vector<VECTOR2D> pts;
for( int i = 0; i < ro.PointCount(); i++ )
{
double xp = (double) ro.CPoint( i ).x * ( origW / upscaledW ) + minX;

View File

@ -385,7 +385,7 @@ public:
void PostprocessNestedPolygons();
protected:
///< List of imported shapes
/// List of imported shapes.
std::list<std::unique_ptr<IMPORTED_SHAPE>> m_shapes;
};

View File

@ -191,16 +191,17 @@ bool SVG_IMPORT_PLUGIN::Import()
{
if( filled && !path->closed )
{
// KiCad doesn't support a single object representing a filled shape that is *not* closed
// so create a filled, closed shape for the fill, and an unfilled, open shape for the outline
// KiCad doesn't support a single object representing a filled shape that is
// *not* closed so create a filled, closed shape for the fill, and an unfilled,
// open shape for the outline
static IMPORTED_STROKE noStroke( -1, LINE_STYLE::SOLID, COLOR4D::UNSPECIFIED );
DrawPath( path->pts, path->npts, true, noStroke, true, fillColor );
DrawPath( path->pts, path->npts, false, stroke, false, COLOR4D::UNSPECIFIED );
}
else
{
// Either the shape has fill and no stroke, so we implicitly close it (for no difference),
// or it's really closed
// Either the shape has fill and no stroke, so we implicitly close it (for no
// difference), or it's really closed.
// We could choose to import a not-filled, closed outline as splines to keep the
// original editability and control points, but currently we don't.
const bool closed = path->closed || filled;
@ -310,6 +311,7 @@ void SVG_IMPORT_PLUGIN::DrawPath( const float* aPoints, int aNumPoints, bool aCl
{
// Closed paths are always polygons, which mean they need to be interpolated
std::vector<VECTOR2D> collectedPathPoints;
if( aNumPoints > 0 )
GatherInterpolatedCubicBezierPath( aPoints, aNumPoints, collectedPathPoints );
@ -489,4 +491,4 @@ void SVG_IMPORT_PLUGIN::ReportMsg( const wxString& aMessage )
// Add message to keep trace of not handled svg entities
m_messages += aMessage;
m_messages += '\n';
}
}

View File

@ -65,12 +65,13 @@ KICOMMON_API bool IncrementString( wxString& name, int aIncrement )
number += aIncrement;
// Don't let result go below zero
if( number > -1 )
{
name.Remove( ii + 1 );
//write out a format string with correct number of leading zeroes
outputFormat.Printf( wxS( "%%0%dld" ), dCount );
//write out the number using the format string
outputNumber.Printf( outputFormat, number );
name << outputNumber << suffix;
@ -96,13 +97,16 @@ std::optional<wxString> STRING_INCREMENTER::Increment( const wxString& aStr, int
while( goodParts < ( aRightIndex + 1 ) && !remaining.IsEmpty() )
{
static const std::regex integerRegex( R"(\d+$)" );
// ABC or abc but not Abc
static const std::regex sameCaseAlphabetRegex( R"(([a-z]+|[A-Z]+)$)" );
// Skippables - for now anything that isn't a letter or number
static const std::regex skipRegex( R"([^a-zA-Z0-9]+$)" );
std::string remainingStr = remaining.ToStdString();
std::smatch match;
if( std::regex_search( remainingStr, match, integerRegex ) )
{
parts.push_back( { match.str(), STRING_PART_TYPE::INTEGER } );
@ -139,10 +143,12 @@ std::optional<wxString> STRING_INCREMENTER::Increment( const wxString& aStr, int
// Reassemble the string - the left-over part, then parts in reverse
wxString result = remaining;
for( auto it = parts.rbegin(); it != parts.rend(); ++it )
{
result << it->first;
}
return result;
}
@ -150,11 +156,13 @@ std::optional<wxString> STRING_INCREMENTER::Increment( const wxString& aStr, int
static bool containsIOSQXZ( const wxString& aStr )
{
static const wxString iosqxz = "IOSQXZ";
for( const wxUniChar& c : aStr )
{
if( iosqxz.Contains( c ) )
return true;
}
return false;
}
@ -185,6 +193,7 @@ bool STRING_INCREMENTER::incrementPart( wxString& aPart, STRING_PART_TYPE aType,
{
aPart = wxString( "0", oldLen - aPart.Len() ) + aPart;
}
return true;
}

View File

@ -94,8 +94,10 @@ std::map<wxString, wxString> ALTIUM_ASCII_PARSER::ReadProperties()
// convert the strings to wxStrings, since we use them everywhere
// value can have non-ASCII characters, so we convert them from LATIN1/ISO8859-1
wxString key( keyS.c_str(), wxConvISO8859_1 );
// Altium stores keys either in Upper, or in CamelCase. Lets unify it.
wxString canonicalKey = key.Trim( false ).Trim( true ).MakeUpper();
// If the key starts with '%UTF8%' we have to parse the value using UTF8
wxString value;

View File

@ -191,7 +191,8 @@ ALTIUM_COMPOUND_FILE::GetLibSymbols( const CFB::COMPOUND_FILE_ENTRY* aStart ) co
std::map<wxString, ALTIUM_SYMBOL_DATA> folders;
m_reader->EnumFiles( root, 1, [&]( const CFB::COMPOUND_FILE_ENTRY* tentry, const CFB::utf16string&, int ) -> int
m_reader->EnumFiles( root, 1, [&]( const CFB::COMPOUND_FILE_ENTRY* tentry,
const CFB::utf16string&, int ) -> int
{
wxString dirName = UTF16ToWstring( tentry->name, tentry->nameLen );
@ -199,7 +200,8 @@ ALTIUM_COMPOUND_FILE::GetLibSymbols( const CFB::COMPOUND_FILE_ENTRY* aStart ) co
return 0;
m_reader->EnumFiles( tentry, 1,
[&]( const CFB::COMPOUND_FILE_ENTRY* entry, const CFB::utf16string&, int ) -> int
[&]( const CFB::COMPOUND_FILE_ENTRY* entry,
const CFB::utf16string&, int ) -> int
{
std::wstring fileName = UTF16ToWstring( entry->name, entry->nameLen );
@ -361,8 +363,8 @@ std::map<wxString, wxString> ALTIUM_BINARY_PARSER::ReadProperties(
if( !hasNullByte && !isBinary )
{
wxLogTrace( "ALTIUM", wxT( "Missing null byte at end of property list. Imported data might be "
"malformed or missing." ) );
wxLogTrace( "ALTIUM", wxT( "Missing null byte at end of property list. Imported data "
"might be malformed or missing." ) );
}
// we use std::string because std::string can handle NULL-bytes
@ -411,8 +413,10 @@ std::map<wxString, wxString> ALTIUM_BINARY_PARSER::ReadProperties(
// convert the strings to wxStrings, since we use them everywhere
// value can have non-ASCII characters, so we convert them from LATIN1/ISO8859-1
wxString key( keyS.c_str(), wxConvISO8859_1 );
// Altium stores keys either in Upper, or in CamelCase. Lets unify it.
wxString canonicalKey = key.Trim( false ).Trim( true ).MakeUpper();
// If the key starts with '%UTF8%' we have to parse the value using UTF8
wxString value;
@ -440,4 +444,4 @@ std::map<wxString, wxString> ALTIUM_BINARY_PARSER::ReadProperties(
}
return kv;
}
}

View File

@ -96,7 +96,8 @@ public:
const CFB::COMPOUND_FILE_ENTRY* FindStream( const std::vector<std::string>& aStreamPath ) const;
const CFB::COMPOUND_FILE_ENTRY* FindStream( const CFB::COMPOUND_FILE_ENTRY* aStart, const std::vector<std::string>& aStreamPath ) const;
const CFB::COMPOUND_FILE_ENTRY* FindStream( const CFB::COMPOUND_FILE_ENTRY* aStart,
const std::vector<std::string>& aStreamPath ) const;
const CFB::COMPOUND_FILE_ENTRY* FindStreamSingleLevel( const CFB::COMPOUND_FILE_ENTRY* aEntry,
const std::string aName,
@ -116,7 +117,8 @@ private:
class ALTIUM_BINARY_PARSER
{
public:
ALTIUM_BINARY_PARSER( const ALTIUM_COMPOUND_FILE& aFile, const CFB::COMPOUND_FILE_ENTRY* aEntry );
ALTIUM_BINARY_PARSER( const ALTIUM_COMPOUND_FILE& aFile,
const CFB::COMPOUND_FILE_ENTRY* aEntry );
ALTIUM_BINARY_PARSER( std::unique_ptr<char[]>& aContent, size_t aSize );
~ALTIUM_BINARY_PARSER() = default;
@ -124,6 +126,7 @@ public:
Type Read()
{
const size_t remainingBytes = GetRemainingBytes();
if( remainingBytes >= sizeof( Type ) )
{
Type val = *(Type*) ( m_pos );
@ -188,7 +191,9 @@ public:
remaining -= 8;
if( length <= 2 )
{
length = 0; // for empty strings, not even the null bytes are present
}
else
{
if( length > remaining )
@ -405,6 +410,7 @@ public:
int id = -1;
uint8_t byte = ReadByte();
if( byte != 0xD0 )
throw std::runtime_error( "ALTIUM_COMPRESSED_READER: invalid compressed string" );

View File

@ -129,7 +129,8 @@ wxString AltiumSchSpecialStringsToKiCadVariables( const wxString&
}
else
{
wxString specialString = aString.substr( start, delimiter - start ).Trim().Trim( false );
wxString specialString =
aString.substr( start, delimiter - start ).Trim().Trim( false );
if( specialString.StartsWith( "\"" ) && specialString.EndsWith( "\"" ) )
specialString = specialString.Mid( 1, specialString.Length() - 2 );
@ -155,6 +156,7 @@ wxString AltiumSchSpecialStringsToKiCadVariables( const wxString&
return result;
}
// https://www.altium.com/documentation/altium-designer/text-objects-pcb
wxString AltiumPcbSpecialStringsToKiCadStrings( const wxString& aString,
const std::map<wxString, wxString>& aOverrides )
@ -182,6 +184,7 @@ wxString AltiumPcbSpecialStringsToKiCadStrings( const wxString&
return aString;
}
wxString AltiumPinNamesToKiCad( wxString& aString )
{
if( aString.IsEmpty() )
@ -195,6 +198,7 @@ wxString AltiumPinNamesToKiCad( wxString& aString )
return AltiumPropertyToKiCadString( aString );
}
VECTOR2I AltiumGetEllipticalPos( double aMajor, double aMinor, double aAngleRadians )
{
if( aMajor == 0 || aMinor == 0 )
@ -207,8 +211,9 @@ VECTOR2I AltiumGetEllipticalPos( double aMajor, double aMinor, double aAngleRadi
double radius = numerator / denominator;
VECTOR2I retval( KiROUND( radius * cos( aAngleRadians ) ), KiROUND( radius * sin( aAngleRadians ) ) );
VECTOR2I retval( KiROUND( radius * cos( aAngleRadians ) ),
KiROUND( radius * sin( aAngleRadians ) ) );
return retval;
}
}

View File

@ -54,8 +54,8 @@ int ALTIUM_PROPS_UTILS::ReadInt( const std::map<wxString, wxString>& aProps, con
}
double ALTIUM_PROPS_UTILS::ReadDouble( const std::map<wxString, wxString>& aProps, const wxString& aKey,
double aDefault )
double ALTIUM_PROPS_UTILS::ReadDouble( const std::map<wxString, wxString>& aProps,
const wxString& aKey, double aDefault )
{
const std::map<wxString, wxString>::const_iterator& value = aProps.find( aKey );
@ -73,7 +73,7 @@ double ALTIUM_PROPS_UTILS::ReadDouble( const std::map<wxString, wxString>& aProp
bool ALTIUM_PROPS_UTILS::ReadBool( const std::map<wxString, wxString>& aProps, const wxString& aKey,
bool aDefault )
bool aDefault )
{
const std::map<wxString, wxString>::const_iterator& value = aProps.find( aKey );
@ -85,7 +85,7 @@ bool ALTIUM_PROPS_UTILS::ReadBool( const std::map<wxString, wxString>& aProps, c
int32_t ALTIUM_PROPS_UTILS::ReadKicadUnit( const std::map<wxString, wxString>& aProps,
const wxString& aKey, const wxString& aDefault )
const wxString& aKey, const wxString& aDefault )
{
const wxString& value = ReadString( aProps, aKey, aDefault );
@ -112,7 +112,7 @@ int32_t ALTIUM_PROPS_UTILS::ReadKicadUnit( const std::map<wxString, wxString>& a
wxString ALTIUM_PROPS_UTILS::ReadString( const std::map<wxString, wxString>& aProps,
const wxString& aKey, const wxString& aDefault )
const wxString& aKey, const wxString& aDefault )
{
const auto& utf8Value = aProps.find( wxString( "%UTF8%" ) + aKey );
@ -129,7 +129,7 @@ wxString ALTIUM_PROPS_UTILS::ReadString( const std::map<wxString, wxString>& aPr
wxString ALTIUM_PROPS_UTILS::ReadUnicodeString( const std::map<wxString, wxString>& aProps,
const wxString& aKey, const wxString& aDefault )
const wxString& aKey, const wxString& aDefault )
{
const auto& unicodeFlag = aProps.find( wxS( "UNICODE" ) );
@ -150,4 +150,4 @@ wxString ALTIUM_PROPS_UTILS::ReadUnicodeString( const std::map<wxString, wxStrin
}
return ReadString( aProps, aKey, aDefault );
}
}

View File

@ -221,7 +221,7 @@ void CADSTAR_ARCHIVE_PARSER::LINECODE::Parse( XNODE* aNode, PARSER_CONTEXT* aCon
else
{
THROW_UNKNOWN_PARAMETER_IO_ERROR( wxString::Format( "STYLE %s", styleStr ),
wxString::Format( "LINECODE -> %s", Name ) );
wxString::Format( "LINECODE -> %s", Name ) );
}
}
@ -396,8 +396,8 @@ void CADSTAR_ARCHIVE_PARSER::EVALUE::Parse( XNODE* aNode, PARSER_CONTEXT* aConte
|| ( !GetXmlAttributeIDString( aNode, 1 ).ToLong( &Exponent ) ) )
{
THROW_PARSING_IO_ERROR( wxT( "Base and Exponent" ),
wxString::Format(
"%s->%s", aNode->GetParent()->GetName(), aNode->GetParent()->GetName() ) );
wxString::Format( "%s->%s", aNode->GetParent()->GetName(),
aNode->GetParent()->GetName() ) );
}
}
@ -495,7 +495,8 @@ void CADSTAR_ARCHIVE_PARSER::VERTEX::AppendToChain( SHAPE_LINE_CHAIN* aChainToAp
wxCHECK_MSG( aChainToAppendTo->PointCount() > 0, /*void*/,
"Can't append an arc to vertex to an empty chain" );
aChainToAppendTo->Append( BuildArc( aChainToAppendTo->GetPoint( -1 ), aCadstarToKicadPointCallback),
aChainToAppendTo->Append( BuildArc( aChainToAppendTo->GetPoint( -1 ),
aCadstarToKicadPointCallback ),
aAccuracy );
}
@ -625,7 +626,8 @@ SHAPE_POLY_SET CADSTAR_ARCHIVE_PARSER::SHAPE::ConvertToPolySet(
{
SHAPE_POLY_SET polyset;
wxCHECK( Type != SHAPE_TYPE::OPENSHAPE, polyset ); // We shouldn't convert openshapes to polyset!
// We shouldn't convert openshapes to polyset!
wxCHECK( Type != SHAPE_TYPE::OPENSHAPE, polyset );
polyset.AddOutline( OutlineAsChain( aCadstarToKicadPointCallback, aAccuracy ) );
@ -885,7 +887,7 @@ wxString CADSTAR_ARCHIVE_PARSER::ParseTextFields( const wxString& aTextString,
while( remainingStr.size() > 0 )
{
//Find the start token
// Find the start token
size_t startpos = remainingStr.Find( wxT( "<@" ) );
if( static_cast<int>( startpos ) == wxNOT_FOUND )
@ -2449,7 +2451,8 @@ void CADSTAR_ARCHIVE_PARSER::InsertAttributeAtEnd( XNODE* aNode, wxString aValue
XNODE* CADSTAR_ARCHIVE_PARSER::LoadArchiveFile( const wxString& aFileName,
const wxString& aFileTypeIdentifier, PROGRESS_REPORTER* aProgressReporter )
const wxString& aFileTypeIdentifier,
PROGRESS_REPORTER* aProgressReporter )
{
KEYWORD emptyKeywords[1] = {};
XNODE* rootNode = nullptr;
@ -2488,6 +2491,8 @@ XNODE* CADSTAR_ARCHIVE_PARSER::LoadArchiveFile( const wxString& aFileName,
if( !aProgressReporter->KeepRefreshing() )
{
delete rootNode;
// @spellingerror
THROW_IO_ERROR( _( "File import cancelled by user." ) );
}
@ -2745,7 +2750,8 @@ long CADSTAR_ARCHIVE_PARSER::GetNumberOfChildNodes( XNODE* aNode )
}
long CADSTAR_ARCHIVE_PARSER::GetNumberOfStepsForReporting( XNODE* aRootNode, std::vector<wxString> aSubNodeChildrenToCount )
long CADSTAR_ARCHIVE_PARSER::GetNumberOfStepsForReporting(
XNODE* aRootNode, std::vector<wxString> aSubNodeChildrenToCount )
{
XNODE* level1Node = aRootNode->GetChildren();
long retval = 0;

View File

@ -87,7 +87,7 @@ class SHAPE_POLY_SET;
class SHAPE_ARC;
/**
* @brief Helper functions and common structures for CADSTAR PCB and Schematic archive files.
* Helper functions and common structures for CADSTAR PCB and Schematic archive files.
*/
class CADSTAR_ARCHIVE_PARSER
{
@ -206,11 +206,12 @@ public:
};
/**
* @brief Replaces CADSTAR fields for the equivalent in KiCad and stores the field values
* in aParserContext
* @param aTextString Text string to parse
* @param aParserContext PARSER_CONTEXT in which to store the values of the found fields
* @return
* Replaces CADSTAR fields for the equivalent in KiCad and stores the field values
* in \a aParserContext.
*
* @param aTextString Text string to parse.
* @param aParserContext #PARSER_CONTEXT in which to store the values of the found fields.
* @return the parsed field.
*/
static wxString ParseTextFields( const wxString& aTextString, PARSER_CONTEXT* aParserContext );
@ -335,10 +336,10 @@ public:
wxString Name = wxT( "CADSTAR" );
long Modifier1 = FONT_NORMAL; ///< It seems this is related to weight. 400=Normal, 700=Bold.
long Modifier2 = 0; ///< It seems this is always 0 regardless of settings
bool KerningPairs =
false; ///< From CADSTAR Help: "Kerning Pairs is for causing the system to
///< automatically reduce the spacing between certain pairs of
///< characters in order to improve the appearance of the text"
bool KerningPairs = false; ///< From CADSTAR Help: "Kerning Pairs is for causing the
///< system to automatically reduce the spacing between
///< certain pairs of characters in order to improve the
///< appearance of the text".
bool Italic = false;
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
@ -388,7 +389,7 @@ public:
/**
* @brief Represents a floating value in E notation
* Represent a floating value in E notation.
*/
struct EVALUE : PARSER
{
@ -400,7 +401,7 @@ public:
};
/**
* @brief Represents a point in x,y coordinates
* Represent a point in x,y coordinates.
*/
struct POINT : VECTOR2I, PARSER
{
@ -436,12 +437,13 @@ public:
};
/**
* @brief Represents a vertex in a shape. E.g. A circle is made by two semicircles with the same
* Represents a vertex in a shape. E.g. A circle is made by two semicircles with the same
* center point.
*/
struct VERTEX : PARSER
{
VERTEX( VERTEX_TYPE aType = VERTEX_TYPE::POINT, POINT aEnd = POINT(), POINT aCenter = POINT() ) :
VERTEX( VERTEX_TYPE aType = VERTEX_TYPE::POINT, POINT aEnd = POINT(),
POINT aCenter = POINT() ) :
Type( aType ), End( aEnd ), Center( aCenter )
{}
@ -462,7 +464,7 @@ public:
};
/**
* @brief Represents a cutout in a closed shape (e.g. OUTLINE)
* Represent a cutout in a closed shape (e.g. OUTLINE).
*/
struct CUTOUT : PARSER
{
@ -593,21 +595,20 @@ public:
/**
* @brief From CADSTAR Help: "Text Alignment enables you to define the position of an alignment
* origin for all text items in CADSTAR. The alignment origin is a point on or within the text
* boundary and defines how the text is displayed.
* From CADSTAR Help: "Text Alignment enables you to define the position of an alignment
* origin for all text items in CADSTAR.
*
* For example, with an alignment of bottom-right the origin will be positioned at the bottom
* right of the text boundary. This makes it easier to right-align several text items
* regardless of the length of text displayed.
* The alignment origin is a point on or within the text boundary and defines how the text
* is displayed. For example, with an alignment of bottom-right the origin will be positioned
* at the bottom right of the text boundary. This makes it easier to right-align several text
* items regardless of the length of text displayed. Text Alignment applies to all CADSTAR
* text. [...]
*
* Text Alignment applies to all CADSTAR text. [...]
*
* Note: Unaligned text operates in the way CADSTAR text always has. In most cases this behaves
* @note Unaligned text operates in the way CADSTAR text always has. In most cases this behaves
* as Bottom Left alignment, but there are a few exceptions, e.g. pin names. Also unaligned
* multiline text has an origin Bottom Left of the first line."
*
* See also JUSTIFICATION
* @see JUSTIFICATION
*/
enum class ALIGNMENT
{
@ -627,13 +628,12 @@ public:
static ALIGNMENT ParseAlignment( XNODE* aNode );
/**
* @brief From CADSTAR Help: "Multi Line Text can also be justified as Left, Centre or Right.
* From CADSTAR Help: "Multi Line Text can also be justified as Left, Centre or Right.
*
* This does not affect the text alignment. Note: Justification of single line text has no
* effect."
* effect." This only affects multiline text
*
* This only affects multiline text
*
* See also ALIGNMENT
* @see ALIGNMENT
*/
enum class JUSTIFICATION
{
@ -646,12 +646,12 @@ public:
static JUSTIFICATION ParseJustification( XNODE* aNode );
/**
* @brief Sets the readability direction of text. From CADSTAR Help: "Horizontal text will
* always be displayed from left to right (i.e. never upside down). Vertical text can be set as
* readable from either the left or right edge of the design."
* Sets the readability direction of text. From CADSTAR Help: "Horizontal text will
* always be displayed from left to right (i.e. never upside down).
*
* I.e. Vertical text can either be rotated 90 degrees clockwise or 90 degrees anticlockwise from
* horizontal. This does not impact vertical text
* Vertical text can be set as readable from either the left or right edge of the design."
* I.e. Vertical text can either be rotated 90 degrees clockwise or 90 degrees counterclockwise
* from horizontal. This does not impact vertical text.
*/
enum class READABILITY
{
@ -725,7 +725,7 @@ public:
/**
* @brief NOTE from CADSTAR help: To convert a Part Definition Attribute into a hyperlink, prefix
* NOTE from CADSTAR help: To convert a Part Definition Attribute into a hyperlink, prefix
* the attribute name with "Link "
*/
struct ATTRNAME : PARSER
@ -783,7 +783,7 @@ public:
/**
* @brief Corresponds to CADSTAR "origin". This is used for setting a location of an attribute
* Corresponds to CADSTAR "origin". This is used for setting a location of an attribute
* e.g. Designator (called Component Name in CADSTAR), Part Name (name of component in the
* library), etc. The atom identifier is "TEXTLOC"
*/
@ -792,7 +792,7 @@ public:
TEXT_LOCATION()
{
// The default alignment for TEXT_LOCATION (when "NO_ALIGNMENT" is selected) is
// Bottom left, matching CADSTAR's default behaviour
// Bottom left, matching CADSTAR's default behavior
Alignment = ALIGNMENT::BOTTOMLEFT;
}
ATTRIBUTE_ID AttributeID;
@ -834,14 +834,12 @@ public:
};
/**
* @brief Corresponds to "Display when" Item property. From CADSTAR
* Help: "This parameter enables you to make the visibility of
* a component outline/area (or an area of component copper, or
* a string of component text) dependent on the current mirror
* status of the component.
* Corresponds to "Display when" Item property.
*
* For example, you may require a string of component text to
* be displayed only when the component is mirrored."
* From CADSTAR Help: "This parameter enables you to make the visibility of a component
* outline/area (or an area of component copper, or a string of component text) dependent
* on the current mirror status of the component. For example, you may require a string
* of component text to be displayed only when the component is mirrored."
*/
enum class SWAP_RULE
{
@ -867,7 +865,7 @@ public:
/**
* @brief References an element from a design reuse block
* References an element from a design reuse block.
*/
struct REUSEBLOCKREF : PARSER
{
@ -994,9 +992,9 @@ public:
wxString Identifier = wxEmptyString; ///< This should match a pad identifier
///< in the component footprint
///< subnode="PINIDENTIFIER". It is assumed
///< that this could be empty in earlier
///< versions of CADSTAR
///< subnode="PINIDENTIFIER". It is
///< assumed that this could be empty in
///< earlier versions of CADSTAR
wxString Name = wxEmptyString; ///< Can be empty. If empty the pin name
///< displayed will be Identifier
///< (subnode="PINNAME")
@ -1028,7 +1026,6 @@ public:
///< the pin (It is unclear what the units
///< are, but only accepted values are
///< integers) subnode ="PINLOAD"
///
CADSTAR_PIN_POSITION Position =
CADSTAR_PIN_POSITION::TOP_RIGHT; ///< The pin names will use these positions
///< when the symbol is added to a design
@ -1157,7 +1154,7 @@ public:
NETELEMENT_ID ID; ///< First character is "J"
LAYER_ID LayerID;
POINT Location;
GROUP_ID GroupID = wxEmptyString; ///< If not empty, this JUCTION is part of a
GROUP_ID GroupID = wxEmptyString; ///< If not empty, this JUNCTION is part of a
///< group
REUSEBLOCKREF ReuseBlockRef;
bool Fixed = false;
@ -1289,7 +1286,8 @@ public:
static void InsertAttributeAtEnd( XNODE* aNode, wxString aValue );
/**
* @brief Reads a CADSTAR Archive file (S-parameter format)
* Reads a CADSTAR Archive file (S-parameter format).
*
* @param aFileName
* @param aFileTypeIdentifier Identifier of the first node in the file to check against.
E.g. "CADSTARPCB"
@ -1303,25 +1301,22 @@ public:
PROGRESS_REPORTER* aProgressReporter = nullptr );
/**
* @brief
* @param aAttribute
* @return
*/
static bool IsValidAttribute( wxXmlAttribute* aAttribute );
/**
* @brief
* @param aNode
* @param aID
* @param aIsRequired Prevents exception throwing if false.
* @return returns the value (wxString) of attribute "attrX" in aNode where 'X' is aID
* @throws IO_ERROR if attribute does not exist
*/
static wxString GetXmlAttributeIDString(
XNODE* aNode, unsigned int aID, bool aIsRequired = true );
static wxString GetXmlAttributeIDString( XNODE* aNode, unsigned int aID,
bool aIsRequired = true );
/**
* @brief
* @param aNode
* @param aID
* @param aIsRequired Prevents exception throwing if false.
@ -1331,21 +1326,18 @@ public:
static long GetXmlAttributeIDLong( XNODE* aNode, unsigned int aID, bool aIsRequired = true );
/**
* @brief
* @param aNode
* @throw IO_ERROR if a child node was found
*/
static void CheckNoChildNodes( XNODE* aNode );
/**
* @brief
* @param aNode
* @throw IO_ERROR if a node adjacent to aNode was found
*/
static void CheckNoNextNodes( XNODE* aNode );
/**
* @brief
* @param aNode with a child node containing an EVALUE
* @param aValueToParse
* @throw IO_ERROR if unable to parse or node is not an EVALUE
@ -1353,8 +1345,8 @@ public:
static void ParseChildEValue( XNODE* aNode, PARSER_CONTEXT* aContext, EVALUE& aValueToParse );
/**
* @brief if no children are present, it just returns an empty
* vector (without throwing an exception)
* If no children are present, it just returns an empty vector (without throwing an exception).
*
* @param aNode containing a series of POINT objects
* @param aTestAllChildNodes
* @param aExpectedNumPoints if UNDEFINED_VALUE (i.e. -1), this is check is disabled
@ -1362,14 +1354,16 @@ public:
* @throw IO_ERROR if one of the following:
* - Unable to parse a POINT object
* - aTestAllChildNodes is true and one of the child nodes is not a valid POINT object
* - aExpectedNumPoints is non-negative and the number of POINT objects found is different
* - aExpectedNumPoints is non-negative and the number of POINT objects found is
* different
*/
static std::vector<POINT> ParseAllChildPoints( XNODE* aNode, PARSER_CONTEXT* aContext,
bool aTestAllChildNodes = false, int aExpectedNumPoints = UNDEFINED_VALUE );
bool aTestAllChildNodes = false,
int aExpectedNumPoints = UNDEFINED_VALUE );
/**
* @brief if no children are present, it just returns an empty
* vector (without throwing an exception)
* If no children are present, it just returns an empty vector (without throwing an exception).
*
* @param aNode containing a series of VERTEX objects
* @param aTestAllChildNodes
* @param aExpectedNumPoints if -1, this is check is disabled
@ -1378,12 +1372,12 @@ public:
* - Unable to parse a VERTEX object
* - aTestAllChildNodes is true and one of the child nodes is not a valid VERTEX object
*/
static std::vector<VERTEX> ParseAllChildVertices(
XNODE* aNode, PARSER_CONTEXT* aContext, bool aTestAllChildNodes = false );
static std::vector<VERTEX> ParseAllChildVertices( XNODE* aNode, PARSER_CONTEXT* aContext,
bool aTestAllChildNodes = false );
/**
* @brief if no children are present, it just returns an empty
* vector (without throwing an exception)
* If no children are present, it just returns an empty vector (without throwing an exception).
*
* @param aNode containing a series of CUTOUT objects
* @param aTestAllChildNodes
* @param aExpectedNumPoints if -1, this is check is disabled
@ -1392,8 +1386,8 @@ public:
* - Unable to parse a CUTOUT object
* - aTestAllChildNodes is true and one of the child nodes is not a valid CUTOUT object
*/
static std::vector<CUTOUT> ParseAllChildCutouts(
XNODE* aNode, PARSER_CONTEXT* aContext, bool aTestAllChildNodes = false );
static std::vector<CUTOUT> ParseAllChildCutouts( XNODE* aNode, PARSER_CONTEXT* aContext,
bool aTestAllChildNodes = false );
static long GetNumberOfChildNodes( XNODE* aNode );
@ -1412,16 +1406,19 @@ public:
}
/**
* @brief Convert a string with CADSTAR overbar characters to equivalent in KiCad
* Convert a string with CADSTAR overbar characters to equivalent in KiCad.
*
* @param aCadstarString Input string
* @return KiCad string with overbar characters
*/
*/
static wxString HandleTextOverbar( wxString aCadstarString );
/**
* Corrects the position of a text element that had NO_ALIGNMENT in CADSTAR. Assumes that the
* provided text element has been initialised with a position and orientation.
* @param aKiCadTextItem a Kicad item to correct
* Correct the position of a text element that had NO_ALIGNMENT in CADSTAR.
*
* Assumes that the provided text element has been initialised with a position and orientation.
*
* @param aKiCadTextItem a KiCad item to correct
*/
static void FixTextPositionNoAlignment( EDA_TEXT* aKiCadTextItem );
@ -1429,7 +1426,7 @@ public:
protected:
void checkPoint(); ///< Updates m_progressReporter or throws if user cancelled
void checkPoint(); ///< Updates m_progressReporter or throws if user canceled
PARSER_CONTEXT m_context;
PROGRESS_REPORTER* m_progressReporter; // optional; may be nullptr

View File

@ -48,13 +48,15 @@ struct WHITESPACE_OR_CONTINUATION : sor<WHITESPACE, LINE_CONTINUATION> {};
* String segment( no line continuation ), with exclusion rules
*/
template <typename... EXCLUSION_RULES>
struct STR_SEGMENT_EXCLUDING : plus<not_at<sor<eolf, LINE_CONTINUATION, EXCLUSION_RULES...>>, any>{};
struct STR_SEGMENT_EXCLUDING : plus<not_at<sor<eolf, LINE_CONTINUATION,
EXCLUSION_RULES...>>, any>{};
/**
* String with optional line continuation and exclusion rules
*/
template <typename... EXCLUSION_RULES>
struct STRING_EXCLUDING : plus<STR_SEGMENT_EXCLUDING<EXCLUSION_RULES...>, opt<LINE_CONTINUATION>> {};
struct STRING_EXCLUDING : plus<STR_SEGMENT_EXCLUDING<EXCLUSION_RULES...>,
opt<LINE_CONTINUATION>> {};
/**
@ -122,7 +124,7 @@ struct FORMAT : seq
CURRENT_FORMAT_NUMBER,
opt<eol>
>
{};
{};
// Newer Parts files have possibility of specifying a tree-like structure to show hierarchy
@ -150,7 +152,7 @@ struct HIERARCHY_NODE_ENTRY :
star<HIERARCHY_PART_NAME, star<WHITESPACE_OR_CONTINUATION>>, // 'part1' 'part2'
opt<eol>
>
{};
{};
// **************
// * PART ENTRY *
@ -166,7 +168,7 @@ struct PART_NAME_FILTER : sor<spaced_ch<'('>, spaced_ch<':'>, spaced_ch<';'>>{};
struct PART_NUMBER_FILTER : one<')'>{};
struct PART_VERSION_FILTER : spaced_ch<';'>{};
// part header elements:
// part header elements:
struct PART_NAME : STRING_EXCLUDING<PART_NAME_FILTER> {};
struct PART_NUMBER : STRING_IN_BRACKETS {};
struct PART_VERSION : STRING_EXCLUDING<PART_VERSION_FILTER> {};
@ -189,11 +191,11 @@ struct PART_HEADER :
// --------------------
//<PCB Component Refname>[_(<PCB Alternate Refname>)]
// string filters:
// string filters:
struct PCB_COMPONENT_FILTER : spaced_ch<'('>{};
struct PCB_ALTERNATE_FILTER : one<')'>{};
// pcb component elements
// pcb component elements
struct PCB_COMPONENT : STRING_EXCLUDING<PCB_COMPONENT_FILTER> {};
struct PCB_ALTERNATE : STRING_IN_BRACKETS {};
@ -370,7 +372,7 @@ struct EXTERNAL_SWAP_GROUP :
// Part Definition
// -----------
//[*DFN_<Definition name>]
// [*DFN_<Definition name>]
struct DEFINITION_NAME : STRING_EXCLUDING<> {};
struct DFN_LINE :
seq
@ -383,7 +385,7 @@ struct DFN_LINE :
>
{};
//[*NGS]
// [*NGS]
struct NGS_LINE :
seq
<
@ -393,7 +395,7 @@ struct NGS_LINE :
>
{};
//[*NPV]
// [*NPV]
struct NPV_LINE :
seq
<
@ -403,7 +405,7 @@ struct NPV_LINE :
>
{};
//[*STM_<Component name stem>]
// [*STM_<Component name stem>]
struct STEM : STRING_EXCLUDING<> {};
struct STM_LINE :
seq
@ -416,7 +418,7 @@ struct STM_LINE :
>
{};
//[*MXP <Maximum number of connector pins>]
// [*MXP <Maximum number of connector pins>]
struct MAX_PIN_COUNT : plus<digit> {};
struct MXP_LINE :
seq
@ -429,7 +431,7 @@ struct MXP_LINE :
>
{};
//[*SPI_[(<Part name>)]_[<Model>]_<Component Value>]
// [*SPI_[(<Part name>)]_[<Model>]_<Component Value>]
struct SPICE_PART_NAME : STRING_IN_BRACKETS {};
struct SPICE_MODEL : sor<QUOTED_STRING, STRING_EXCLUDING<>> {};
struct SPI_LINE :
@ -446,7 +448,7 @@ struct SPI_LINE :
{};
//[*PAC_(<Part name>)_<Acceptance Text>]
// [*PAC_(<Part name>)_<Acceptance Text>]
struct ACCEPTANCE_PART_NAME : STRING_IN_BRACKETS {};
struct ACCEPTANCE_TEXT : STRING_EXCLUDING<> {};
struct PAC_LINE :
@ -464,7 +466,7 @@ struct PAC_LINE :
// User defined part attributes
// -----------
//[*<User-defined name>_<Value>]
// [*<User-defined name>_<Value>]
struct USER_PART_ATTRIBUTE_NAME : sor<QUOTED_STRING, STRING_EXCLUDING<WHITESPACE>> {};
struct USER_PART_ATTRIBUTE_VALUE : STRING_EXCLUDING<> {};
struct USER_PART_ATTRIBUTE :
@ -499,28 +501,28 @@ struct GENERIC_ATTRIBUTE :
>
{};
//[$[!]<SCM Attribute name>(<Attribute value>)]
// [$[!]<SCM Attribute name>(<Attribute value>)]
struct SCM_ATTRIBUTE : GENERIC_ATTRIBUTE<'$'>{};
//[%[!]<PCB Attribute name>(<Attribute value>)]
// [%[!]<PCB Attribute name>(<Attribute value>)]
struct PCB_ATTRIBUTE : GENERIC_ATTRIBUTE<'%'>{};
//[~[!]<Parts Library Attribute Name>(<Attribute Value>)]
// [~[!]<Parts Library Attribute Name>(<Attribute Value>)]
struct PART_ATTRIBUTE : GENERIC_ATTRIBUTE<'~'>{};
//[@[!]<SCM/PCB Attribute name>(<Attribute value>)]
// [@[!]<SCM/PCB Attribute name>(<Attribute value>)]
struct SCH_PCB_ATTRIBUTE : GENERIC_ATTRIBUTE<'@'>{};
//[<SCM Symbol Refname>][_(<SCM Alternate Refname>)]
// [<SCM Symbol Refname>][_(<SCM Alternate Refname>)]
struct SCH_NAME : sor<QUOTED_STRING, STRING_EXCLUDING<spaced_ch<'('>>> {};
struct SCH_ALTERNATE : STRING_IN_BRACKETS {};
struct SCH_SYMBOL_LINE : seq<SCH_NAME, opt<SCH_ALTERNATE>, opt<eol>>{};
//[<PinIdentifier>[.<Position>] [!<Pintype>] [:<Loading>]]
// [<PinIdentifier>[.<Position>] [!<Pintype>] [:<Loading>]]
struct PIN_IDENTIFIER : plus<digit>{};
struct PIN_POSITION : range<'0', '3'>{};
struct PIN_TYPE : star<alpha>{};
@ -553,41 +555,42 @@ struct HIDDEN_PIN_ENTRY : seq<PIN_SIGNAL_NAME, plus<WHITESPACE>, PIN_LIST, opt<e
struct PART_ENTRY :
seq
<
PART_HEADER, //.<Part name>[ (1234): 1 ;<Description>]
PART_PCB_COMPONENT, //<PCB Component Refname> [(Alternate)]
PART_HEADER, // .<Part name>[ (1234): 1 ;<Description>]
PART_PCB_COMPONENT, // <PCB Component Refname> [(Alternate)]
// In any order:
star<sor<
PART_VALUE, //[*VALUE <Value>]
PIN_NAMES_LIST, //[*PNM <ID><Name>[ <ID><Name>] ...]
PIN_LABELS_LIST, //[*PLB <ID><Label>[ <ID><Label>] ...]
PIN_EQUIVALENCES, //[*EQU_<ID>=<ID>[=<ID>=<ID>_etc ...]]
INTERNAL_SWAP_GROUP, //[*SYM SYM1 |*INT 2 3 |*INT 4 5]
EXTERNAL_SWAP_GROUP, //[*SYM SYM1 |*EXT 2 3 |*EXT 4 5]
DFN_LINE, //[*DFN_<Definition name>]
NGS_LINE, //[*NGS]
NPV_LINE, //[*NPV]
STM_LINE, //[*STM_<Component name stem>]
MXP_LINE, //[*MXP <Maximum number of connector pins>]
SPI_LINE, //[*SPI_[(<Part name>)]_[<Model>]_<Component Value>]
PAC_LINE, //[*PAC_(<Part name>)_<Acceptance Text>]
USER_PART_ATTRIBUTE, //[*<User-defined name>_<Value>]
SCM_ATTRIBUTE, //[$[!]<SCM Attribute name>(<Attribute value>)]
PCB_ATTRIBUTE, //[%[!]<PCB Attribute name>(<Attribute value>)]
PART_ATTRIBUTE, //[~[!]<Parts Library Attribute Name>(<Attribute Value>)]
SCH_PCB_ATTRIBUTE //[@[!]<SCM/PCB Attribute name>(<Attribute value>)]
PART_VALUE, // [*VALUE <Value>]
PIN_NAMES_LIST, // [*PNM <ID><Name>[ <ID><Name>] ...]
PIN_LABELS_LIST, // [*PLB <ID><Label>[ <ID><Label>] ...]
PIN_EQUIVALENCES, // [*EQU_<ID>=<ID>[=<ID>=<ID>_etc ...]]
INTERNAL_SWAP_GROUP, // [*SYM SYM1 |*INT 2 3 |*INT 4 5]
EXTERNAL_SWAP_GROUP, // [*SYM SYM1 |*EXT 2 3 |*EXT 4 5]
DFN_LINE, // [*DFN_<Definition name>]
NGS_LINE, // [*NGS]
NPV_LINE, // [*NPV]
STM_LINE, // [*STM_<Component name stem>]
MXP_LINE, // [*MXP <Maximum number of connector pins>]
SPI_LINE, // [*SPI_[(<Part name>)]_[<Model>]_<Component Value>]
PAC_LINE, // [*PAC_(<Part name>)_<Acceptance Text>]
USER_PART_ATTRIBUTE, // [*<User-defined name>_<Value>]
SCM_ATTRIBUTE, // [$[!]<SCM Attribute name>(<Attribute value>)]
PCB_ATTRIBUTE, // [%[!]<PCB Attribute name>(<Attribute value>)]
PART_ATTRIBUTE, // [~[!]<Parts Library Attribute Name>(<Attribute
// Value>)]
SCH_PCB_ATTRIBUTE // [@[!]<SCM/PCB Attribute name>(<Attribute value>)]
>>,
star<SYMBOL_ENTRY>, //[<SCM Symbol Refname>][_(<SCM Alternate Refname>)]
//[Pin entry] [Pin entry] ...
star<SYMBOL_ENTRY>, // [<SCM Symbol Refname>][_(<SCM Alternate Refname>)]
// [Pin entry] [Pin entry] ...
star<HIDDEN_PIN_ENTRY> //[/<Signame>_<Pin entry>]
star<HIDDEN_PIN_ENTRY> // [/<Signame>_<Pin entry>]
>
{};
/**
* Grammar for CADSTAR Parts Library file format (*.lib)
* Grammar for CADSTAR Parts Library file format (*.lib).
*/
struct GRAMMAR :
must<
@ -611,8 +614,9 @@ struct GRAMMAR :
/**
* Grammar to parse the file header only.
*
* In general a valid file should have `#FORMAT 32` in the first line but there appear to be some
* files that ommit the format specifier and start straight away with the part definitions. Just
* files that omit the format specifier and start straight away with the part definitions. Just
* in case, we will also allow the first part to be up to 5 lines into the file (arbitrary number
* just to limit the time spent in reading a file header to determine whether it is valid).
*/

View File

@ -69,7 +69,8 @@ struct CADSTAR_PART_ENTRY
bool m_PinsVisible = true;
/**
* Map of pin identifiers to alphanumeric pin names
* Map of pin identifiers to alphanumeric pin names.
*
* Pin names can be a maximum of 10 characters
* (Typically used for naming of BGA pads - equivalent to KiCad Pin Numbers)
*
@ -78,39 +79,41 @@ struct CADSTAR_PART_ENTRY
std::map<long, std::string> m_PinNamesMap;
/**
* Map of pin identifiers to alphanumeric pin labels. Equivalent to KiCad Pin Names
* Map of pin identifiers to alphanumeric pin labels.
*
* Equivalent to KiCad Pin Names
*
* E.g: *PLB 1=STROBE 2=OFFSET 3=OFFSET 5=+ 6=+v
*/
std::map<long, std::string> m_PinLabelsMap;
/**
* Groups of pins that are interchangeable with each other
* Groups of pins that are interchangeable with each other.
*
* E.g: *EQU 2=1, 6=5, 8=9=10, 12=13
*/
std::vector<std::vector<long>> m_PinEquivalences;
/**
* Groups of INTERNAL gates that are interchangeable with each other
* Groups of INTERNAL gates that are interchangeable with each other.
*
* E.g: *SYM SYM1
* *INT 1 3
* *INT 2 5
*
* The gate described by pins 1 and 3 above, can be swapped internally with the gate decribed
* The gate described by pins 1 and 3 above, can be swapped internally with the gate described
* by pins 2 and 5 but they CANNOT be swapped with gates in another part
*/
std::vector<CADSTAR_SWAP_GROUP> m_InternalSwapGroup;
/**
* Groups of EXTERNAL gates that are interchangeable with each other
* Groups of EXTERNAL gates that are interchangeable with each other.
*
* E.g: *SYM SYM2
* *EXT 1 3
* *EXT 2 5
*
* The gate described by pins 1 and 3 above, can be swapped internally with the gate decribed
* The gate described by pins 1 and 3 above, can be swapped internally with the gate described
* by pins 2 and 5 AND they can be swapped with same gates in another part
*/
std::vector<CADSTAR_SWAP_GROUP> m_ExternalSwapGroup;
@ -119,7 +122,8 @@ struct CADSTAR_PART_ENTRY
* Star (*) line
* *<User-defined name> <Value>
* This line is ignored by CADSTAR. Usually they are used by third party tools.
* These lines are treated as attributes of the Parts library (i.e. Attribute Type = Parts Library).
* These lines are treated as attributes of the Parts library (i.e. Attribute Type =
* Parts Library).
*/
std::map<std::string, std::string> m_UserAttributes;
@ -158,7 +162,7 @@ struct CADSTAR_PART_ENTRY
std::map<std::string, CADSTAR_ATTRIBUTE_VALUE> m_PartAttributes;
/**
* Symbols that form this part
* Symbols that form this part.
*/
std::vector<CADSTAR_PART_SYMBOL_ENTRY> m_Symbols;
@ -226,8 +230,9 @@ struct CADSTAR_SWAP_GROUP
std::optional<std::string> m_Name;
/**
* Each gate is a list of pin identifiers. The order of the pins is important
* as it defines the equivalence between gates
* Each gate is a list of pin identifiers.
*
* The order of the pins is important as it defines the equivalence between gates.
*/
std::vector<std::vector<long>> m_Gates;
};
@ -237,7 +242,7 @@ struct CADSTAR_PART_NODE
{
std::optional<long> m_ParentNodeIdx;
std::string m_Name;
std::vector<std::string> m_PartNames; ///< Part names belonging to this hierarchy
std::vector<std::string> m_PartNames; ///< Part names belonging to this hierarchy.
};
#endif //CADSTAR_PARTS_LIB_MODEL_H

View File

@ -55,16 +55,16 @@ typedef std::unordered_map<wxString, wxXmlNode*> NODE_MAP;
typedef std::map<wxString, EINSTANCE*> EINSTANCE_MAP;
typedef std::map<wxString, std::unique_ptr<EPART>> EPART_MAP;
///< Translates Eagle special characters to their counterparts in KiCad.
/// Translates Eagle special characters to their counterparts in KiCad.
wxString escapeName( const wxString& aNetName );
///< Interprets special characters in Eagle text and converts them to KiCAD notation.
/// Interprets special characters in Eagle text and converts them to KiCAD notation.
wxString interpretText( const wxString& aText );
///< Translates Eagle special text reference to a KiCad variable reference
/// Translates Eagle special text reference to a KiCad variable reference.
bool substituteVariable( wxString* aText );
///< Converts Eagle's HTML description into KiCad description format
/// Converts Eagle's HTML description into KiCad description format.
wxString convertDescription( wxString aDescr );
static inline wxXmlNode* getChildrenNodes( NODE_MAP& aMap, const wxString& aName )
@ -140,13 +140,13 @@ public:
p.back().value = aValue;
}
/// modify the last path node's attribute
/// 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
/// Return the contents of the XPATH as a single string.
wxString Contents()
{
typedef std::vector<TRIPLET>::const_iterator CITER_TRIPLET;
@ -178,7 +178,7 @@ public:
/**
* Convert a wxString to a generic type T.
*
* @param aValue is a wxString containing the value that will be converted to type T.
* @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.
*/
@ -217,9 +217,9 @@ public:
{}
/**
* @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.
* @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.
*/
OPTIONAL_XML_ATTRIBUTE( const wxString& aData )
{
@ -231,8 +231,8 @@ public:
}
/**
* @param aData is the value of the XML attribute. If this constructor is called, the
* attribute is available.
* @param aData is the value of the XML attribute. If this constructor is called, the
* attribute is available.
*/
template<typename V = T>
OPTIONAL_XML_ATTRIBUTE( T aData ) :
@ -380,7 +380,7 @@ size_t GetNodeCount( const wxXmlNode* aNode );
*/
NODE_MAP MapChildren( wxXmlNode* aCurrentNode );
///< Convert an Eagle curve end to a KiCad center for S_ARC
/// Convert an Eagle curve end to a KiCad center for S_ARC.
VECTOR2I ConvertArcCenter( const VECTOR2I& aStart, const VECTOR2I& aEnd, double aAngle );
// Pre-declare for typedefs
@ -402,7 +402,7 @@ struct EAGLE_BASE
IO_BASE* io;
/*
/**
* Send a message to the #IO_BASE #REPORTER object if one exists.
*
* @param aMsg is the message to send to the #REPORTER object.
@ -447,10 +447,10 @@ struct ECOORD : public EAGLE_BASE
EU_MIL, ///< mils/thous
};
///< Value expressed in nanometers
/// Value expressed in nanometers.
long long int value;
///< Unit used for the value field
/// Unit used for the value field.
static constexpr EAGLE_UNIT ECOORD_UNIT = EU_NM;
ECOORD()
@ -503,7 +503,7 @@ struct ECOORD : public EAGLE_BASE
return value == aOther.value;
}
///< Converts a size expressed in a certain unit to nanometers.
/// Converts a size expressed in a certain unit to nanometers.
static long long int ConvertToNm( int aValue, enum EAGLE_UNIT aUnit );
};

View File

@ -50,6 +50,7 @@
d.name = j.at( #name ).get<double>(); \
}
void EASYEDA::from_json( const nlohmann::json& j, EASYEDA::DOC_TYPE& d )
{
if( j.is_string() )
@ -66,6 +67,7 @@ void EASYEDA::from_json( const nlohmann::json& j, EASYEDA::DOC_TYPE& d )
}
}
void EASYEDA::from_json( const nlohmann::json& j, EASYEDA::HEAD& d )
{
PARSE_VALUE( docType );
@ -81,6 +83,7 @@ void EASYEDA::from_json( const nlohmann::json& j, EASYEDA::HEAD& d )
PARSE_TO_DOUBLE( y, 0 );
}
void EASYEDA::from_json( const nlohmann::json& j, EASYEDA::DOCUMENT& d )
{
PARSE_VALUE( docType );
@ -92,6 +95,7 @@ void EASYEDA::from_json( const nlohmann::json& j, EASYEDA::DOCUMENT& d )
PARSE_VALUE( dataStr );
}
void EASYEDA::from_json( const nlohmann::json& j, EASYEDA::DOCUMENT_PCB& d )
{
PARSE_VALUE( c_para );
@ -101,16 +105,19 @@ void EASYEDA::from_json( const nlohmann::json& j, EASYEDA::DOCUMENT_PCB& d )
d.DRCRULE = j.at( "DRCRULE" );
}
void EASYEDA::from_json( const nlohmann::json& j, EASYEDA::DOCUMENT_SYM& d )
{
PARSE_VALUE( c_para );
}
void EASYEDA::from_json( const nlohmann::json& j, EASYEDA::DOCUMENT_SCHEMATICS& d )
{
PARSE_VALUE( schematics );
}
void EASYEDA::from_json( const nlohmann::json& j, EASYEDA::C_PARA& d )
{
PARSE_VALUE( package );

View File

@ -58,7 +58,8 @@ void IterateZipFiles(
std::vector<nlohmann::json> ParseJsonLines( wxInputStream& aInput, const wxString& aSource );
/**
* Multiple document types (e.g. footprint and PCB) can be put into a single file, separated by empty line.
* Multiple document types (e.g. footprint and PCB) can be put into a single file, separated by
* empty line.
*/
std::vector<std::vector<nlohmann::json>> ParseJsonLinesWithSeparation( wxInputStream& aInput,
const wxString& aSource );

View File

@ -61,6 +61,7 @@ void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::SCH_ATTR& d )
d.fontStyle = j.at( 10 ).get<wxString>();
}
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::PCB_ATTR& d )
{
d.id = j.at( 1 ).get<wxString>();
@ -159,6 +160,7 @@ void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::SYM_PIN& d )
d.inverted = j.at( 9 ).get<int>() == 2;
}
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::SYM_HEAD& d )
{
if( !j.at( 1 ).is_object() )
@ -174,6 +176,7 @@ void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::SYM_HEAD& d )
}
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::PRJ_SHEET& d )
{
d.name = j.value( "name", "" );
@ -181,18 +184,21 @@ void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::PRJ_SHEET& d )
d.id = j.value( "id", 0 );
}
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::PRJ_SCHEMATIC& d )
{
d.name = j.value( "name", "" );
d.sheets = j.value( "sheets", std::vector<PRJ_SHEET>{} );
}
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::PRJ_BOARD& d )
{
d.schematic = j.value( "schematic", "" );
d.pcb = j.value( "pcb", "" );
}
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::PRJ_SYMBOL& d )
{
if( j.at( "source" ).is_string() )
@ -221,6 +227,7 @@ void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::PRJ_SYMBOL& d )
d.custom_tags = j.at( "custom_tags" );
}
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::PRJ_FOOTPRINT& d )
{
if( j.at( "source" ).is_string() )
@ -249,6 +256,7 @@ void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::PRJ_FOOTPRINT&
d.custom_tags = j.at( "custom_tags" );
}
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::PRJ_DEVICE& d )
{
if( j.at( "source" ).is_string() )
@ -277,12 +285,14 @@ void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::PRJ_DEVICE& d )
d.attributes = AnyMapToStringMap( j.at( "attributes" ) );
}
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::BLOB& d )
{
d.objectId = j.at( 1 ).get<wxString>();
d.url = j.at( 3 ).get<wxString>();
}
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::POURED& d )
{
d.pouredId = j.at( 1 ).get<wxString>();
@ -290,4 +300,4 @@ void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::POURED& d )
d.unki = j.at( 3 ).get<int>();
d.isPoly = j.at( 4 ).get<bool>();
d.polyData = j.at( 5 );
}
}

View File

@ -43,13 +43,15 @@ wxString IO_BASE::IO_FILE_DESC::FileFilter() const
}
void IO_BASE::CreateLibrary( const wxString& aLibraryPath, const std::map<std::string, UTF8>* aProperties )
void IO_BASE::CreateLibrary( const wxString& aLibraryPath,
const std::map<std::string, UTF8>* aProperties )
{
NOT_IMPLEMENTED( __FUNCTION__ );
}
bool IO_BASE::DeleteLibrary( const wxString& aLibraryPath, const std::map<std::string, UTF8>* aProperties )
bool IO_BASE::DeleteLibrary( const wxString& aLibraryPath,
const std::map<std::string, UTF8>* aProperties )
{
NOT_IMPLEMENTED( __FUNCTION__ );
}

Some files were not shown because too many files have changed in this diff Show More