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 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_mgr.h>
31#include <pin_type.h>
32#include <layer_ids.h>
33#include <wx/filename.h>
34#include <plotters/plotter.h>
35
36
37class EDA_TEXT;
38class LIB_SHAPE;
39class LIB_FIELD;
40class LIB_PIN;
41class SCH_LABEL_BASE;
42class SCH_SYMBOL;
43class SCH_TEXT;
44class SCH_SHAPE;
45
46namespace EASYEDAPRO
47{
49{
51 wxString number;
52 wxString name;
53};
54
56{
58 std::vector<PIN_INFO> pins;
59 std::unique_ptr<LIB_SYMBOL> libSymbol;
60 std::optional<EASYEDAPRO::SCH_ATTR> symbolAttr;
61 std::map<wxString, int> partUnits;
62};
63} // namespace EASYEDAPRO
64
65
67{
68
69public:
70 explicit SCH_EASYEDAPRO_PARSER( SCHEMATIC* aSchematic, PROGRESS_REPORTER* aProgressReporter );
72
73 /*void Parse( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
74 const std::map<ALTIUM_PCB_DIR, std::string>& aFileMapping );*/
75
76 static double Convert( wxString aValue );
77
78 template <typename T>
79 static T ScaleSize( T aValue )
80 {
81 return KiROUND( schIUScale.MilsToIU( aValue * 10 ) );
82 }
83
84 template <typename T>
86 {
87 return VECTOR2<T>( ScaleSize( aValue.x ), ScaleSize( aValue.y ) );
88 }
89
90 template <typename T>
92 {
93 return VECTOR2<T>( ScaleSize( aValue.x ), -ScaleSize( aValue.y ) );
94 }
95
96 template <typename T>
98 {
99 return VECTOR2<T>( ScaleSize( aValue.x ), ScaleSize( aValue.y ) );
100 }
101
102 double SizeToKi( wxString units );
103
104 EASYEDAPRO::SYM_INFO ParseSymbol( const std::vector<nlohmann::json>& aLines );
105
106 void ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet,
107 const nlohmann::json& aProject,
108 std::map<wxString, EASYEDAPRO::SYM_INFO>& aSymbolMap,
109 const std::map<wxString, EASYEDAPRO::BLOB>& aBlobMap,
110 const std::vector<nlohmann::json>& aLines, const wxString& aLibName );
111
112protected:
114
115 template <typename T>
116 void ApplyFontStyle( const std::map<wxString, nlohmann::json>& fontStyles, T& text,
117 const wxString& styleStr );
118
119 template <typename T>
120 void ApplyLineStyle( const std::map<wxString, nlohmann::json>& lineStyles, T& shape,
121 const wxString& styleStr );
122
123 template <typename T>
124 void ApplyAttrToField( const std::map<wxString, nlohmann::json>& fontStyles, T* text,
125 const EASYEDAPRO::SCH_ATTR& aAttr, bool aIsSym, bool aToSym,
126 SCH_SYMBOL* aParent = nullptr );
127};
128
129
130#endif // SCH_EASYEDAPRO_PARSER_H_
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
Field object used in symbol libraries.
Definition: lib_field.h:62
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)
EASYEDAPRO::SYM_INFO ParseSymbol(const std::vector< nlohmann::json > &aLines)
static VECTOR2< T > ScalePosSym(VECTOR2< T > aValue)
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)
void ApplyAttrToField(const std::map< wxString, nlohmann::json > &fontStyles, T *text, const EASYEDAPRO::SCH_ATTR &aAttr, bool aIsSym, bool aToSym, SCH_SYMBOL *aParent=nullptr)
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:81
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:94
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:85