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