KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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 SCH_EASYEDAPRO_PARSER_H_
22#define SCH_EASYEDAPRO_PARSER_H_
23
25
26#include <sch_io/sch_io_mgr.h>
27#include <pin_type.h>
28#include <layer_ids.h>
29#include <plotters/plotter.h>
30
31
32class EDA_TEXT;
33class SCH_SYMBOL;
34
35namespace EASYEDAPRO
36{
38{
40 wxString number;
41 wxString name;
42};
43
45{
47 std::vector<PIN_INFO> pins;
48 std::unique_ptr<LIB_SYMBOL> libSymbol;
49 std::optional<EASYEDAPRO::SCH_ATTR> symbolAttr;
50 std::map<wxString, int> partUnits;
51};
52} // namespace EASYEDAPRO
53
54
56{
57
58public:
59 explicit SCH_EASYEDAPRO_PARSER( SCHEMATIC* aSchematic, PROGRESS_REPORTER* aProgressReporter );
61
62 /*void Parse( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
63 const std::map<ALTIUM_PCB_DIR, std::string>& aFileMapping );*/
64
65 static double Convert( wxString aValue );
66
67 template <typename T>
68 static T ScaleSize( T aValue )
69 {
70 return KiROUND( schIUScale.MilsToIU( aValue * 10 ) );
71 }
72
73 template <typename T>
75 {
76 return VECTOR2<T>( ScaleSize( aValue.x ), ScaleSize( aValue.y ) );
77 }
78
79 template <typename T>
81 {
82 return VECTOR2<T>( ScaleSize( aValue.x ), -ScaleSize( aValue.y ) );
83 }
84
85 template <typename T>
87 {
88 return VECTOR2<T>( ScaleSize( aValue.x ), -ScaleSize( aValue.y ) );
89 }
90
91 double SizeToKi( wxString units );
92
93 EASYEDAPRO::SYM_INFO ParseSymbol( const std::vector<nlohmann::json>& aLines,
94 const std::map<wxString, wxString>& aDeviceAttributes );
95
96 void ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet,
97 const nlohmann::json& aProject,
98 std::map<wxString, EASYEDAPRO::SYM_INFO>& aSymbolMap,
99 const std::map<wxString, EASYEDAPRO::BLOB>& aBlobMap,
100 const std::vector<nlohmann::json>& aLines, const wxString& aLibName );
101
102protected:
104
105 wxString ResolveFieldVariables( const wxString aInput,
106 const std::map<wxString, wxString>& aDeviceAttributes );
107
108 template <typename T>
109 void ApplyFontStyle( const std::map<wxString, nlohmann::json>& fontStyles, T& text,
110 const wxString& styleStr );
111
112 template <typename T>
113 void ApplyLineStyle( const std::map<wxString, nlohmann::json>& lineStyles, T& shape,
114 const wxString& styleStr );
115
116 template <typename T>
117 void ApplyAttrToField( const std::map<wxString, nlohmann::json>& fontStyles, T* text,
118 const EASYEDAPRO::SCH_ATTR& aAttr, bool aIsSym, bool aToSym,
119 const std::map<wxString, wxString>& aDeviceAttributes = {},
120 SCH_SYMBOL* aParent = nullptr );
121};
122
123
124#endif // SCH_EASYEDAPRO_PARSER_H_
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:89
A progress reporter interface for use in multi-threaded environments.
Holds all the data relating to one schematic.
Definition schematic.h:90
static double Convert(wxString aValue)
static VECTOR2< T > ScalePos(VECTOR2< T > aValue)
double SizeToKi(wxString units)
static T ScaleSize(T aValue)
void ApplyFontStyle(const std::map< wxString, nlohmann::json > &fontStyles, T &text, const wxString &styleStr)
static VECTOR2< T > ScalePosSym(VECTOR2< T > aValue)
SCH_EASYEDAPRO_PARSER(SCHEMATIC *aSchematic, PROGRESS_REPORTER *aProgressReporter)
EASYEDAPRO::SYM_INFO ParseSymbol(const std::vector< nlohmann::json > &aLines, const std::map< wxString, wxString > &aDeviceAttributes)
void ApplyAttrToField(const std::map< wxString, nlohmann::json > &fontStyles, T *text, const EASYEDAPRO::SCH_ATTR &aAttr, bool aIsSym, bool aToSym, const std::map< wxString, wxString > &aDeviceAttributes={}, SCH_SYMBOL *aParent=nullptr)
void ParseSchematic(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const nlohmann::json &aProject, std::map< wxString, EASYEDAPRO::SYM_INFO > &aSymbolMap, const std::map< wxString, EASYEDAPRO::BLOB > &aBlobMap, const std::vector< nlohmann::json > &aLines, const wxString &aLibName)
wxString ResolveFieldVariables(const wxString aInput, const std::map< wxString, wxString > &aDeviceAttributes)
void ApplyLineStyle(const std::map< wxString, nlohmann::json > &lineStyles, T &shape, const wxString &styleStr)
static VECTOR2< T > ScaleSize(VECTOR2< T > aValue)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:44
Schematic symbol object.
Definition sch_symbol.h:69
Define a general 2D-vector/point.
Definition vector2d.h:67
EASYEDAPRO::SYM_PIN pin
std::unique_ptr< LIB_SYMBOL > libSymbol
std::vector< PIN_INFO > pins
std::optional< EASYEDAPRO::SCH_ATTR > symbolAttr
std::map< wxString, int > partUnits
EASYEDAPRO::SYM_HEAD head