KiCad PCB EDA Suite
altium_designer_plugin.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 <thomas.pointhuber@gmx.at>
5  * Copyright (C) 2020 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 
30 #include <iomanip>
31 
32 #include <wx/string.h>
33 
34 #include <altium_designer_plugin.h>
35 #include <altium_pcb.h>
36 
37 #include <board.h>
38 
39 #include <compoundfilereader.h>
40 #include <utf.h>
41 
43 {
44  m_board = nullptr;
45  m_props = nullptr;
46 }
47 
48 
50 {
51 }
52 
53 
54 const wxString ALTIUM_DESIGNER_PLUGIN::PluginName() const
55 {
56  return wxT( "Altium Designer" );
57 }
58 
59 
61 {
62  return wxT( "PcbDoc" );
63 }
64 
65 
66 BOARD* ALTIUM_DESIGNER_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
67  const PROPERTIES* aProperties, PROJECT* aProject )
68 {
69  m_props = aProperties;
70 
71  m_board = aAppendToMe ? aAppendToMe : new BOARD();
72 
73  // Give the filename to the board if it's new
74  if( !aAppendToMe )
75  m_board->SetFileName( aFileName );
76 
77  // clang-format off
78  const std::map<ALTIUM_PCB_DIR, std::string> mapping = {
79  { ALTIUM_PCB_DIR::FILE_HEADER, "FileHeader" },
80  { ALTIUM_PCB_DIR::ARCS6, "Arcs6\\Data" },
81  { ALTIUM_PCB_DIR::BOARD6, "Board6\\Data" },
82  { ALTIUM_PCB_DIR::BOARDREGIONS, "BoardRegions\\Data" },
83  { ALTIUM_PCB_DIR::CLASSES6, "Classes6\\Data" },
84  { ALTIUM_PCB_DIR::COMPONENTS6, "Components6\\Data" },
85  { ALTIUM_PCB_DIR::COMPONENTBODIES6, "ComponentBodies6\\Data" },
86  { ALTIUM_PCB_DIR::DIMENSIONS6, "Dimensions6\\Data" },
87  { ALTIUM_PCB_DIR::FILLS6, "Fills6\\Data" },
88  { ALTIUM_PCB_DIR::MODELS, "Models\\Data" },
89  { ALTIUM_PCB_DIR::NETS6, "Nets6\\Data" },
90  { ALTIUM_PCB_DIR::PADS6, "Pads6\\Data" },
91  { ALTIUM_PCB_DIR::POLYGONS6, "Polygons6\\Data" },
92  { ALTIUM_PCB_DIR::REGIONS6, "Regions6\\Data" },
93  { ALTIUM_PCB_DIR::RULES6, "Rules6\\Data" },
94  { ALTIUM_PCB_DIR::SHAPEBASEDREGIONS6, "ShapeBasedRegions6\\Data" },
95  { ALTIUM_PCB_DIR::TEXTS6, "Texts6\\Data" },
96  { ALTIUM_PCB_DIR::TRACKS6, "Tracks6\\Data" },
97  { ALTIUM_PCB_DIR::VIAS6, "Vias6\\Data" }
98  };
99  // clang-format on
100 
101  ParseAltiumPcb( m_board, aFileName, mapping );
102 
103  return m_board;
104 }
Container for project specific data.
Definition: project.h:62
A name/value tuple with unique names and optional values.
Definition: properties.h:33
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties, PROJECT *aProject=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
const wxString GetFileExtension() const override
Returns the file extension for the PLUGIN.
void SetFileName(const wxString &aFileName)
Definition: board.h:298
const wxString PluginName() const override
Return a brief hard coded name for this PLUGIN.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void ParseAltiumPcb(BOARD *aBoard, const wxString &aFileName, const std::map< ALTIUM_PCB_DIR, std::string > &aFileMapping)
Helper method which opens a Altium Board File and parses it.
Definition: altium_pcb.cpp:52