KiCad PCB EDA Suite
altium_circuit_maker_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  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
29 #include <iomanip>
30 
31 #include <wx/string.h>
32 
34 #include <altium_pcb.h>
35 
36 #include <class_board.h>
37 
38 #include <compoundfilereader.h>
39 #include <utf.h>
40 
42 {
43  m_board = nullptr;
44  m_props = nullptr;
45 }
46 
47 
49 {
50 }
51 
52 
54 {
55  return wxT( "Altium Circuit Maker" );
56 }
57 
58 
60 {
61  return wxT( "CMPcbDoc" );
62 }
63 
64 
66  const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
67 {
68  m_props = aProperties;
69 
70  m_board = aAppendToMe ? aAppendToMe : new BOARD();
71 
72  // Give the filename to the board if it's new
73  if( !aAppendToMe )
74  m_board->SetFileName( aFileName );
75 
76  // clang-format off
77  const std::map<ALTIUM_PCB_DIR, std::string> mapping = {
78  { ALTIUM_PCB_DIR::FILE_HEADER, "FileHeader" },
79  { ALTIUM_PCB_DIR::ARCS6, "1CEEB63FB33847F8AFC4485F64735E\\Data" },
80  { ALTIUM_PCB_DIR::BOARD6, "96B09F5C6CEE434FBCE0DEB3E88E70\\Data" },
81  { ALTIUM_PCB_DIR::BOARDREGIONS, "E3A544335C30403A991912052C936F\\Data" },
82  { ALTIUM_PCB_DIR::CLASSES6, "4F71DD45B09143988210841EA1C28D\\Data" },
83  { ALTIUM_PCB_DIR::COMPONENTS6, "F9D060ACC7DD4A85BC73CB785BAC81\\Data" },
84  { ALTIUM_PCB_DIR::COMPONENTBODIES6, "44D9487C98CE4F0EB46AB6E9CDAF40\\Data" }, // or: A0DB41FBCB0D49CE8C32A271AA7EF5 ?
85  { ALTIUM_PCB_DIR::DIMENSIONS6, "068B9422DBB241258BA2DE9A6BA1A6\\Data" },
86  { ALTIUM_PCB_DIR::FILLS6, "6FFE038462A940E9B422EFC8F5D85E\\Data" },
87  { ALTIUM_PCB_DIR::MODELS, "0DB009C021D946C88F1B3A32DAE94B\\Data" },
88  { ALTIUM_PCB_DIR::NETS6, "35D7CF51BB9B4875B3A138B32D80DC\\Data" },
89  { ALTIUM_PCB_DIR::PADS6, "4F501041A9BC4A06BDBDAB67D3820E\\Data" },
90  { ALTIUM_PCB_DIR::POLYGONS6, "A1931C8B0B084A61AA45146575FDD3\\Data" },
91  { ALTIUM_PCB_DIR::REGIONS6, "F513A5885418472886D3EF18A09E46\\Data" },
92  { ALTIUM_PCB_DIR::RULES6, "C27718A40C94421388FAE5BD7785D7\\Data" },
93  { ALTIUM_PCB_DIR::SHAPEBASEDREGIONS6,"BDAA2C70289849078C8EBEEC7F0848\\Data" },
94  { ALTIUM_PCB_DIR::TEXTS6, "A34BC67C2A5F408D8F377378C5C5E2\\Data" },
95  { ALTIUM_PCB_DIR::TRACKS6, "412A754DBB864645BF01CD6A80C358\\Data" },
96  { ALTIUM_PCB_DIR::VIAS6, "C87A685A0EFA4A90BEEFD666198B56\\Data" }
97  };
98  // clang-format on
99 
100  ParseAltiumPcb( m_board, aFileName, mapping );
101 
102  return m_board;
103 }
const wxString PluginName() const override
Function PluginName returns a brief hard coded name for this PLUGIN.
PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties) override
Function Load loads information from some input file format that this PLUGIN implementation knows abo...
void SetFileName(const wxString &aFileName)
Definition: class_board.h:242
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:178
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:50
const wxString GetFileExtension() const override
Function GetFileExtension returns the file extension for the PLUGIN.