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
45{
46public:
47 explicit PCB_IO_EASYEDAPRO_PARSER( BOARD* aBoard, PROGRESS_REPORTER* aProgressReporter );
49
50 PCB_LAYER_ID LayerToKi( int aLayer );
51
52 template <typename T>
53 static T ScaleSize( T aValue )
54 {
55 return KiROUND( aValue * 25400.0 / 500.0 ) * 500;
56 }
57
58 template <typename T>
60 {
61 return VECTOR2<T>( ScaleSize( aValue.x ), ScaleSize( aValue.y ) );
62 }
63
64 template <typename T>
66 {
67 return VECTOR2<T>( ScaleSize( aValue.x ), -ScaleSize( aValue.y ) );
68 }
69
70 static double Convert( wxString aValue );
71
72 FOOTPRINT* ParseFootprint( const nlohmann::json& aProject, const wxString& aFpUuid,
73 const std::vector<nlohmann::json>& aLines );
74
75 void ParseBoard( BOARD* aBoard, const nlohmann::json& aProject,
76 std::map<wxString, std::unique_ptr<FOOTPRINT>>& aFootprintMap,
77 const std::map<wxString, EASYEDAPRO::BLOB>& aBlobMap,
78 const std::multimap<wxString, EASYEDAPRO::POURED>& aPouredMap,
79 const std::vector<nlohmann::json>& aLines, const wxString& aFpLibName );
80
81 std::vector<std::unique_ptr<PCB_SHAPE>> ParsePoly( BOARD_ITEM_CONTAINER* aContainer,
82 nlohmann::json polyData, bool aClosed,
83 bool aInFill ) const;
84
85 SHAPE_LINE_CHAIN ParseContour( nlohmann::json polyData, bool aInFill,
86 int aMaxError = SHAPE_ARC::DefaultAccuracyForPCB() ) const;
87
88private:
91
92 NETINFO_ITEM* getNet( BOARD* aBoard, const wxString& aNetName );
93
94 std::unique_ptr<PAD> createPAD( FOOTPRINT* aFootprint, const nlohmann::json& line );
95
96 void fillFootprintModelInfo( FOOTPRINT* footprint, const wxString& modelUuid,
97 const wxString& modelTitle, const wxString& modelTransform ) const;
98};
99
100
101#endif // PCB_IO_EASYEDAPRO_PARSER_H_
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
Abstract interface for BOARD_ITEMs capable of storing other items inside.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
Handle the data for a net.
Definition netinfo.h:46
static VECTOR2< T > ScaleSize(VECTOR2< T > aValue)
static VECTOR2< T > ScalePos(VECTOR2< T > aValue)
PCB_IO_EASYEDAPRO_PARSER(BOARD *aBoard, PROGRESS_REPORTER *aProgressReporter)
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 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)
FOOTPRINT * ParseFootprint(const nlohmann::json &aProject, const wxString &aFpUuid, const std::vector< nlohmann::json > &aLines)
static double Convert(wxString aValue)
void fillFootprintModelInfo(FOOTPRINT *footprint, const wxString &modelUuid, const wxString &modelTitle, const wxString &modelTransform) const
A progress reporter interface for use in multi-threaded environments.
static int DefaultAccuracyForPCB()
Definition shape_arc.h:279
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:682