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 (C) 2023 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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef PCB_IO_EASYEDAPRO_PARSER_H_
26#define PCB_IO_EASYEDAPRO_PARSER_H_
27
29
30#include <cstdint>
31#include <cstring>
32#include <memory>
33#include <vector>
34#include <map>
35#include <optional>
36
37#include <wx/string.h>
38#include <wx/arrstr.h>
39
40#include <nlohmann/json.hpp>
42#include <pcb_shape.h>
43
44class BOARD;
46
48{
49public:
50 explicit PCB_IO_EASYEDAPRO_PARSER( BOARD* aBoard, PROGRESS_REPORTER* aProgressReporter );
52
53 PCB_LAYER_ID LayerToKi( int aLayer );
54
55 template <typename T>
56 static T ScaleSize( T aValue )
57 {
58 return KiROUND( aValue * 25400 / 500 ) * 500;
59 }
60
61 template <typename T>
63 {
64 return VECTOR2<T>( ScaleSize( aValue.x ), ScaleSize( aValue.y ) );
65 }
66
67 template <typename T>
69 {
70 return VECTOR2<T>( ScaleSize( aValue.x ), -ScaleSize( aValue.y ) );
71 }
72
73 static double Convert( wxString aValue );
74
75 FOOTPRINT* ParseFootprint( const nlohmann::json& aProject, const wxString& aFpUuid,
76 const std::vector<nlohmann::json>& aLines );
77
78 void ParseBoard( BOARD* aBoard, const nlohmann::json& aProject,
79 std::map<wxString, std::unique_ptr<FOOTPRINT>>& aFootprintMap,
80 const std::map<wxString, EASYEDAPRO::BLOB>& aBlobMap,
81 const std::multimap<wxString, EASYEDAPRO::POURED>& aPouredMap,
82 const std::vector<nlohmann::json>& aLines, const wxString& aFpLibName );
83
84 std::vector<std::unique_ptr<PCB_SHAPE>> ParsePoly( BOARD_ITEM_CONTAINER* aContainer,
85 nlohmann::json polyData, bool aClosed,
86 bool aInFill ) const;
87
88 SHAPE_LINE_CHAIN ParseContour( nlohmann::json polyData, bool aInFill,
89 double aArcAccuracy = SHAPE_ARC::DefaultAccuracyForPCB() ) const;
90
91private:
94
95 std::unique_ptr<PAD> createPAD( FOOTPRINT* aFootprint, const nlohmann::json& line );
96
97 void fillFootprintModelInfo( FOOTPRINT* footprint, const wxString& modelUuid,
98 const wxString& modelTitle, const wxString& modelTransform ) const;
99};
100
101
102#endif // PCB_IO_EASYEDAPRO_PARSER_H_
Abstract interface for BOARD_ITEMs capable of storing other items inside.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:282
static VECTOR2< T > ScaleSize(VECTOR2< T > aValue)
SHAPE_LINE_CHAIN ParseContour(nlohmann::json polyData, bool aInFill, double aArcAccuracy=SHAPE_ARC::DefaultAccuracyForPCB()) const
static VECTOR2< T > ScalePos(VECTOR2< T > aValue)
std::vector< std::unique_ptr< PCB_SHAPE > > ParsePoly(BOARD_ITEM_CONTAINER *aContainer, nlohmann::json polyData, bool aClosed, bool aInFill) 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)
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 double DefaultAccuracyForPCB()
Definition: shape_arc.h:224
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:70
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:118