KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_solidworks.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) 2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <wx/string.h>
21
22#include <pcb_io_solidworks.h>
24#include <altium_pcb.h>
26#include <pcb_io/pcb_io.h>
27#include <reporter.h>
28
29#include <board.h>
30
31#include <compoundfilereader.h>
32#include <utf.h>
33
34PCB_IO_SOLIDWORKS::PCB_IO_SOLIDWORKS() : PCB_IO( wxS( "Solidworks PCB" ) )
35{
38}
39
40
42{
43}
44
45
46bool PCB_IO_SOLIDWORKS::CanReadBoard( const wxString& aFileName ) const
47{
48 if( !PCB_IO::CanReadBoard( aFileName ) )
49 return false;
50
52}
53
54
55BOARD* PCB_IO_SOLIDWORKS::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
56 const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
57{
58 m_props = aProperties;
59
60 m_board = aAppendToMe ? aAppendToMe : new BOARD();
61
62 // Give the filename to the board if it's new
63 if( !aAppendToMe )
64 m_board->SetFileName( aFileName );
65
66 // clang-format off
67 const std::map<ALTIUM_PCB_DIR, std::string> mapping = {
68 { ALTIUM_PCB_DIR::FILE_HEADER, "FileHeader" },
69 { ALTIUM_PCB_DIR::ARCS6, "D2864697BB2D411B857EBD69D74447" },
70 { ALTIUM_PCB_DIR::BOARD6, "21CE7E3D9BFF41679BACA1184CAF54" },
71 { ALTIUM_PCB_DIR::BOARDREGIONS, "67075A4119214CE4AB174F9B1A9A41" },
72 { ALTIUM_PCB_DIR::CLASSES6, "1122D4F14A924F9CA5C2060AF370E0" },
73 { ALTIUM_PCB_DIR::COMPONENTS6, "208CAE8E44BD43D5B3CCA426D9331B" },
74 { ALTIUM_PCB_DIR::COMPONENTBODIES6, "6DDF94E6CB364893BED31C189F9AF3" },
75 { ALTIUM_PCB_DIR::DIMENSIONS6, "6148AE8C77B042798B46830E96BB24" },
76 { ALTIUM_PCB_DIR::FILLS6, "5944DE0E258C41E2B0B382AC964048" },
77 { ALTIUM_PCB_DIR::MODELS, "874F98A7E25A48EDAD394EB891E503" },
78 { ALTIUM_PCB_DIR::NETS6, "0201837ACD434D55B34BBC68B75BAB" },
79 { ALTIUM_PCB_DIR::PADS6, "E4D0C33E25824886ABC7FEEAE7B521" },
80 { ALTIUM_PCB_DIR::POLYGONS6, "7ABD4252549749DD8DB16804819AC3" },
81 { ALTIUM_PCB_DIR::REGIONS6, "6B3892541AB94CD999291D590B5C86" }, // probably wrong; in as a placeholder
82 { ALTIUM_PCB_DIR::RULES6, "7009830ADF65423FA6CCB73A77E710" },
83 { ALTIUM_PCB_DIR::SHAPEBASEDREGIONS6, "91241C66300E4490965070BA56F6F7" },
84 { ALTIUM_PCB_DIR::TEXTS6, "4AF3D139533041489C2A57BBF9890D" },
85 { ALTIUM_PCB_DIR::TRACKS6, "5D0C6E18E16A4BBFAA256C24B79EAE" },
86 { ALTIUM_PCB_DIR::VIAS6, "2AF5387F097242D3A1095B6FAC3397" },
87 { ALTIUM_PCB_DIR::WIDESTRINGS6, "9B378679AF85466C8673A41EE46393" }
88
89 /*
90 * Understood but not needed:
91 * 04A8F96E0E4C478C813AE57CACCD0F - Legacy text storage
92 * 01F1BD1AA06E4D6A9D1ABF0BBFF4A4 - Fwd/Back compatibility messages
93 *
94 * Not yet used by KiCad:
95 * 7C01505E39124E67BCCAB1883B8FB7 - Design Rule Checker Options6
96 * 63B31A3709B54882BFA96424906BE8 - EmbeddedFonts6
97 * 8B83C7E94C1D419B9B2D5505479820 - Pin Swap Options6
98 * F78C10230A794F5C93ACB50AC693B2 - Advanced Placer Options6
99 *
100 * No data yet on:
101 * 1C0DB1ED572645BEB65D029D20406C
102 * 2AA5C1C72BF14315A47DD931B84A79
103 * 6468C28D32CC4867AB374091CC8431
104 * 6B3892541AB94CD999291D590B5C86
105 * 8675F4105E444E6D9B2BEE6273769D
106 * B983FCC2B6DE46E0B94006B6393235
107 * D6551D22B6DB44659C3F32F7E1949D
108 *
109 * Not yet identified:
110 * D06DD2E4A51C4A3EA96D9ED8C8F3F3
111 * F9C465994DE840579ED19E820C19C2
112 *
113 * Region-like objects that don't map cleanly (maybe Solidworks sketches?)
114 * 84958494F3F54075975C4E199DB8EB
115 * 2E731D36D1F049428744F0661F3E44
116 */
117 };
118 // clang-format on
119
120 ALTIUM_COMPOUND_FILE altiumPcbFile( aFileName );
121
122 try
123 {
124 // Parse File
126 pcb.Parse( altiumPcbFile, mapping );
127 }
128 catch( CFB::CFBException& exception )
129 {
130 THROW_IO_ERROR( exception.what() );
131 }
132
133 return m_board;
134}
void Parse(const ALTIUM_COMPOUND_FILE &aAltiumPcbFile, const std::map< ALTIUM_PCB_DIR, std::string > &aFileMapping)
Definition: altium_pcb.cpp:314
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:215
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
Definition: io_base.h:218
LAYER_MAPPING_HANDLER m_layer_mapping_handler
Callback to get layer mapping.
virtual void RegisterLayerMappingCallback(LAYER_MAPPING_HANDLER aLayerMappingHandler)
Register a different handler to be called when mapping of input layers to KiCad layers occurs.
static bool checkFileHeader(const wxString &aFileName)
static std::map< wxString, PCB_LAYER_ID > DefaultLayerMappingCallback(const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
Return the automapped layers.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties, PROJECT *aProject=nullptr) 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.
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.
static REPORTER & GetInstance()
Definition: reporter.cpp:212
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:39