KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_altium_circuit_studio.cpp
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) 2019 Thomas Pointhuber <[email protected]>
5 * Copyright (C) 2020-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
29#include <wx/string.h>
30
33#include <altium_pcb.h>
35#include <pcb_io/pcb_io.h>
36
37#include <board.h>
38
39#include <compoundfilereader.h>
40#include <utf.h>
41
43{
44}
45
46
48{
49}
50
51
52bool PCB_IO_ALTIUM_CIRCUIT_STUDIO::CanReadBoard( const wxString& aFileName ) const
53{
54 if( !PCB_IO::CanReadBoard( aFileName ) )
55 return false;
56
58}
59
60
61BOARD* PCB_IO_ALTIUM_CIRCUIT_STUDIO::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
62 const STRING_UTF8_MAP* aProperties,
63 PROJECT* aProject )
64{
65 m_props = aProperties;
66
67 m_board = aAppendToMe ? aAppendToMe : new BOARD();
68
69 // Give the filename to the board if it's new
70 if( !aAppendToMe )
71 m_board->SetFileName( aFileName );
72
73 // clang-format off
74 const std::map<ALTIUM_PCB_DIR, std::string> mapping = {
75 { ALTIUM_PCB_DIR::FILE_HEADER, "FileHeader" },
76 { ALTIUM_PCB_DIR::ARCS6, "00C595EB90524FFC8C3BD9670020A2" },
77 { ALTIUM_PCB_DIR::BOARD6, "88857D7F1DF64F7BBB61848C965636" },
78 { ALTIUM_PCB_DIR::BOARDREGIONS, "8957CF30F167408D9D263D23FE7C89" },
79 { ALTIUM_PCB_DIR::CLASSES6, "847EFBF87A5149B1AA326A52AD6357" },
80 { ALTIUM_PCB_DIR::COMPONENTS6, "465416896A15486999A39C643935D2" },
81 { ALTIUM_PCB_DIR::COMPONENTBODIES6, "1849D9B5512D452A93EABF4E40B122" }, // or B6AD30D75241498BA2536EBF001752 ?
82 { ALTIUM_PCB_DIR::DIMENSIONS6, "16C81DBC13C447FF8B42A426677F3C" },
83 { ALTIUM_PCB_DIR::FILLS6, "4E83BDC3253747F08E9006D7F57020" },
84 { ALTIUM_PCB_DIR::MODELS, "C0F7599ECC6A4D648DF5BB557679AF" },
85 { ALTIUM_PCB_DIR::NETS6, "D95A0DA2FE9047779A5194C127F30B" },
86 { ALTIUM_PCB_DIR::PADS6, "47D69BC5107A4B8DB8DAA23E39C238" },
87 { ALTIUM_PCB_DIR::POLYGONS6, "D7038392280E4E229B9D9B5426B295" },
88 { ALTIUM_PCB_DIR::REGIONS6, "FFDDC21382BB42FE8A7D0C328D272C" },
89 { ALTIUM_PCB_DIR::RULES6, "48B2FA96DB7546818752B34373D6C6" },
90 { ALTIUM_PCB_DIR::SHAPEBASEDREGIONS6, "D5F54B536E124FB89E2D51B1121508" },
91 { ALTIUM_PCB_DIR::TEXTS6, "349ABBB211DB4F5B8AE41B1B49555A" },
92 { ALTIUM_PCB_DIR::TRACKS6, "530C20C225354B858B2578CAB8C08D" },
93 { ALTIUM_PCB_DIR::VIAS6, "CA5F5989BCDB404DA70A9D1D3D5758" },
94 { ALTIUM_PCB_DIR::WIDESTRINGS6, "87FBF0C5BC194B909FF42199450A76" }
95 };
96 // clang-format on
97
98 ALTIUM_COMPOUND_FILE altiumPcbFile( aFileName );
99
100 try
101 {
102 // Parse File
104 pcb.Parse( altiumPcbFile, mapping );
105 }
106 catch( CFB::CFBException& exception )
107 {
108 THROW_IO_ERROR( exception.what() );
109 }
110
111 return m_board;
112}
void Parse(const ALTIUM_COMPOUND_FILE &aAltiumPcbFile, const std::map< ALTIUM_PCB_DIR, std::string > &aFileMapping)
Definition: altium_pcb.cpp:303
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:282
void SetFileName(const wxString &aFileName)
Definition: board.h:317
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
Definition: io_base.h:210
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
Definition: io_base.h:213
PCB_IO_ALTIUM_CIRCUIT_STUDIO()
Pcbnew PLUGIN for Altium *.PcbDoc format.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties, PROJECT *aProject) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
static bool checkFileHeader(const wxString &aFileName)
A base class that BOARD loading and saving plugins should derive from.
Definition: pcb_io.h:72
BOARD * m_board
The board BOARD being worked on, no ownership here.
Definition: pcb_io.h:343
const STRING_UTF8_MAP * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Definition: pcb_io.h:346
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
Definition: pcb_io.cpp:43
Container for project specific data.
Definition: project.h:62
A name/value tuple with unique names and optional values.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:39