KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_easyedapro_parser.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 Alex Shvartzkop <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef PCB_IO_EASYEDAPRO_PARSER_H_
22#define PCB_IO_EASYEDAPRO_PARSER_H_
23
25
26#include <cstdint>
27#include <cstring>
28#include <memory>
29#include <vector>
30#include <map>
31#include <optional>
32
33#include <wx/string.h>
34#include <wx/arrstr.h>
35
36#include <json_common.h>
38#include <pcb_shape.h>
39
40class NETINFO_ITEM;
41class BOARD;
43
44class PAD;
45
47{
48public:
49 explicit PCB_IO_EASYEDAPRO_PARSER( BOARD* aBoard, PROGRESS_REPORTER* aProgressReporter );
51
52 PCB_LAYER_ID LayerToKi( int aLayer );
53
54 template <typename T>
55 static T ScaleSize( T aValue )
56 {
57 return KiROUND( aValue * 25400.0 / 500.0 ) * 500;
58 }
59
60 template <typename T>
62 {
63 return VECTOR2<T>( ScaleSize( aValue.x ), ScaleSize( aValue.y ) );
64 }
65
66 template <typename T>
68 {
69 return VECTOR2<T>( ScaleSize( aValue.x ), -ScaleSize( aValue.y ) );
70 }
71
72 static double Convert( wxString aValue );
73
75 static void SizeHoleOnlyPad( PAD& aPad, bool aPlated );
76
78 static nlohmann::json NormalizeSafeSpacing( const nlohmann::json& aTable );
79
80 std::unique_ptr<FOOTPRINT> ParseFootprint( const nlohmann::json& aProject, const wxString& aFpUuid,
81 const std::vector<nlohmann::json>& aLines );
82
83 void ParseBoard( BOARD* aBoard, const nlohmann::json& aProject,
84 std::map<wxString, std::unique_ptr<FOOTPRINT>>& aFootprintMap,
85 const std::map<wxString, EASYEDAPRO::BLOB>& aBlobMap,
86 const std::multimap<wxString, EASYEDAPRO::POURED>& aPouredMap,
87 const std::vector<nlohmann::json>& aLines, const wxString& aFpLibName );
88 wxString GetSafeSpacingRules() const;
89
90
91 std::vector<std::unique_ptr<PCB_SHAPE>> ParsePoly( BOARD_ITEM_CONTAINER* aContainer,
92 nlohmann::json polyData, bool aClosed,
93 bool aInFill ) const;
94
95 SHAPE_LINE_CHAIN ParseContour( nlohmann::json polyData, bool aInFill,
96 int aMaxError = SHAPE_ARC::DefaultAccuracyForPCB() ) const;
97
98 void FillFootprintModelInfo( FOOTPRINT* footprint, const wxString& modelUuid, const wxString& modelTitle,
99 const wxString& modelTransform ) const;
100
101private:
104 nlohmann::json m_safeSpacing;
105
106
107 NETINFO_ITEM* getNet( BOARD* aBoard, const wxString& aNetName );
108
109 std::unique_ptr<PAD> createPAD( FOOTPRINT* aFootprint, const nlohmann::json& line );
110};
111
112
113#endif // PCB_IO_EASYEDAPRO_PARSER_H_
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:985
Abstract interface for BOARD_ITEMs capable of storing other items inside.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
Handle the data for a net.
Definition netinfo.h:50
Definition pad.h:61
static VECTOR2< T > ScaleSize(VECTOR2< T > aValue)
static nlohmann::json NormalizeSafeSpacing(const nlohmann::json &aTable)
Map legacy eight- and ten-row safe-spacing matrices to the v3 category layout.
static void SizeHoleOnlyPad(PAD &aPad, bool aPlated)
A hole with no copper around it takes the drill size, and stays unplated if the source says it is.
static VECTOR2< T > ScalePos(VECTOR2< T > aValue)
PCB_IO_EASYEDAPRO_PARSER(BOARD *aBoard, PROGRESS_REPORTER *aProgressReporter)
std::unique_ptr< FOOTPRINT > ParseFootprint(const nlohmann::json &aProject, const wxString &aFpUuid, const std::vector< nlohmann::json > &aLines)
std::vector< std::unique_ptr< PCB_SHAPE > > ParsePoly(BOARD_ITEM_CONTAINER *aContainer, nlohmann::json polyData, bool aClosed, bool aInFill) const
SHAPE_LINE_CHAIN ParseContour(nlohmann::json polyData, bool aInFill, int aMaxError=SHAPE_ARC::DefaultAccuracyForPCB()) const
NETINFO_ITEM * getNet(BOARD *aBoard, const wxString &aNetName)
void FillFootprintModelInfo(FOOTPRINT *footprint, const wxString &modelUuid, const wxString &modelTitle, const wxString &modelTransform) const
void ParseBoard(BOARD *aBoard, const nlohmann::json &aProject, std::map< wxString, std::unique_ptr< FOOTPRINT > > &aFootprintMap, const std::map< wxString, EASYEDAPRO::BLOB > &aBlobMap, const std::multimap< wxString, EASYEDAPRO::POURED > &aPouredMap, const std::vector< nlohmann::json > &aLines, const wxString &aFpLibName)
std::unique_ptr< PAD > createPAD(FOOTPRINT *aFootprint, const nlohmann::json &line)
PCB_LAYER_ID LayerToKi(int aLayer)
static double Convert(wxString aValue)
A progress reporter interface for use in multi-threaded environments.
static int DefaultAccuracyForPCB()
Definition shape_arc.h:283
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Define a general 2D-vector/point.
Definition vector2d.h:67
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
VECTOR2< double > VECTOR2D
Definition vector2d.h:707