/* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2023 Alex Shvartzkop * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, you may find one here: * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * or you may search the http://www.gnu.org website for the version 2 license, * or you may write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef SCH_EASYEDAPRO_PARSER_H_ #define SCH_EASYEDAPRO_PARSER_H_ #include #include #include #include #include #include class EDA_TEXT; class LIB_SHAPE; class LIB_FIELD; class LIB_PIN; class SCH_LABEL_BASE; class SCH_SYMBOL; class SCH_TEXT; class SCH_SHAPE; namespace EASYEDAPRO { struct PIN_INFO { EASYEDAPRO::SYM_PIN pin; wxString number; wxString name; }; struct SYM_INFO { EASYEDAPRO::SYM_HEAD head; std::vector pins; std::unique_ptr libSymbol; std::optional symbolAttr; std::map partUnits; }; } // namespace EASYEDAPRO class SCH_EASYEDAPRO_PARSER { public: explicit SCH_EASYEDAPRO_PARSER( SCHEMATIC* aSchematic, PROGRESS_REPORTER* aProgressReporter ); ~SCH_EASYEDAPRO_PARSER(); /*void Parse( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile, const std::map& aFileMapping );*/ static double Convert( wxString aValue ); template static T ScaleSize( T aValue ) { return KiROUND( schIUScale.MilsToIU( aValue * 10 ) ); } template static VECTOR2 ScaleSize( VECTOR2 aValue ) { return VECTOR2( ScaleSize( aValue.x ), ScaleSize( aValue.y ) ); } template static VECTOR2 ScalePos( VECTOR2 aValue ) { return VECTOR2( ScaleSize( aValue.x ), -ScaleSize( aValue.y ) ); } template static VECTOR2 ScalePosSym( VECTOR2 aValue ) { return VECTOR2( ScaleSize( aValue.x ), ScaleSize( aValue.y ) ); } double SizeToKi( wxString units ); EASYEDAPRO::SYM_INFO ParseSymbol( const std::vector& aLines ); void ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet, const nlohmann::json& aProject, std::map& aSymbolMap, const std::map& aBlobMap, const std::vector& aLines, const wxString& aLibName ); protected: SCHEMATIC* m_schematic; wxString ResolveFieldVariables( const wxString aInput, const std::map& aDeviceAttributes ); template void ApplyFontStyle( const std::map& fontStyles, T& text, const wxString& styleStr ); template void ApplyLineStyle( const std::map& lineStyles, T& shape, const wxString& styleStr ); template void ApplyAttrToField( const std::map& fontStyles, T* text, const EASYEDAPRO::SCH_ATTR& aAttr, bool aIsSym, bool aToSym, const std::map& aDeviceAttributes = {}, SCH_SYMBOL* aParent = nullptr ); }; #endif // SCH_EASYEDAPRO_PARSER_H_