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 <font/fontconfig.h>
23#include <pcb_io_solidworks.h>
25#include <altium_pcb.h>
28#include <pcb_io/pcb_io.h>
29#include <reporter.h>
30
31#include <board.h>
32
33#include <compoundfilereader.h>
34#include <utf.h>
35
37 PCB_IO( wxS( "Solidworks PCB" ) )
38{
41}
42
43
45{
46}
47
48
49bool PCB_IO_SOLIDWORKS::CanReadBoard( const wxString& aFileName ) const
50{
51 if( !PCB_IO::CanReadBoard( aFileName ) )
52 return false;
53
55}
56
57
58BOARD* PCB_IO_SOLIDWORKS::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
59 const std::map<std::string, UTF8>* aProperties, PROJECT* aProject )
60{
61 m_props = aProperties;
62
63 m_board = aAppendToMe ? aAppendToMe : new BOARD();
64
66
67 // Give the filename to the board if it's new
68 if( !aAppendToMe )
69 m_board->SetFileName( aFileName );
70
71 // clang-format off
72 const std::map<ALTIUM_PCB_DIR, std::string> mapping = {
73 { ALTIUM_PCB_DIR::FILE_HEADER, "FileHeader" },
74 { ALTIUM_PCB_DIR::ARCS6, "D2864697BB2D411B857EBD69D74447" },
75 { ALTIUM_PCB_DIR::BOARD6, "21CE7E3D9BFF41679BACA1184CAF54" },
76 { ALTIUM_PCB_DIR::BOARDREGIONS, "67075A4119214CE4AB174F9B1A9A41" },
77 { ALTIUM_PCB_DIR::CLASSES6, "1122D4F14A924F9CA5C2060AF370E0" },
78 { ALTIUM_PCB_DIR::COMPONENTS6, "208CAE8E44BD43D5B3CCA426D9331B" },
79 { ALTIUM_PCB_DIR::COMPONENTBODIES6, "6DDF94E6CB364893BED31C189F9AF3" },
80 { ALTIUM_PCB_DIR::DIMENSIONS6, "6148AE8C77B042798B46830E96BB24" },
81 { ALTIUM_PCB_DIR::FILLS6, "5944DE0E258C41E2B0B382AC964048" },
82 { ALTIUM_PCB_DIR::MODELS, "874F98A7E25A48EDAD394EB891E503" },
83 { ALTIUM_PCB_DIR::NETS6, "0201837ACD434D55B34BBC68B75BAB" },
84 { ALTIUM_PCB_DIR::PADS6, "E4D0C33E25824886ABC7FEEAE7B521" },
85 { ALTIUM_PCB_DIR::POLYGONS6, "7ABD4252549749DD8DB16804819AC3" },
86 { ALTIUM_PCB_DIR::REGIONS6, "6B3892541AB94CD999291D590B5C86" }, // probably wrong; in as a placeholder
87 { ALTIUM_PCB_DIR::RULES6, "7009830ADF65423FA6CCB73A77E710" },
88 { ALTIUM_PCB_DIR::SHAPEBASEDREGIONS6, "91241C66300E4490965070BA56F6F7" },
89 { ALTIUM_PCB_DIR::TEXTS6, "4AF3D139533041489C2A57BBF9890D" },
90 { ALTIUM_PCB_DIR::TRACKS6, "5D0C6E18E16A4BBFAA256C24B79EAE" },
91 { ALTIUM_PCB_DIR::VIAS6, "2AF5387F097242D3A1095B6FAC3397" },
92 { ALTIUM_PCB_DIR::WIDESTRINGS6, "9B378679AF85466C8673A41EE46393" }
93
94 /*
95 * Understood but not needed:
96 * 04A8F96E0E4C478C813AE57CACCD0F - Legacy text storage
97 * 01F1BD1AA06E4D6A9D1ABF0BBFF4A4 - Fwd/Back compatibility messages
98 *
99 * Not yet used by KiCad:
100 * 7C01505E39124E67BCCAB1883B8FB7 - Design Rule Checker Options6
101 * 63B31A3709B54882BFA96424906BE8 - EmbeddedFonts6
102 * 8B83C7E94C1D419B9B2D5505479820 - Pin Swap Options6
103 * F78C10230A794F5C93ACB50AC693B2 - Advanced Placer Options6
104 *
105 * No data yet on:
106 * 1C0DB1ED572645BEB65D029D20406C
107 * 2AA5C1C72BF14315A47DD931B84A79
108 * 6468C28D32CC4867AB374091CC8431
109 * 6B3892541AB94CD999291D590B5C86
110 * 8675F4105E444E6D9B2BEE6273769D
111 * B983FCC2B6DE46E0B94006B6393235
112 * D6551D22B6DB44659C3F32F7E1949D
113 *
114 * Not yet identified:
115 * D06DD2E4A51C4A3EA96D9ED8C8F3F3
116 * F9C465994DE840579ED19E820C19C2
117 *
118 * Region-like objects that don't map cleanly (maybe Solidworks sketches?)
119 * 84958494F3F54075975C4E199DB8EB
120 * 2E731D36D1F049428744F0661F3E44
121 */
122 };
123 // clang-format on
124
125 ALTIUM_PCB_COMPOUND_FILE altiumPcbFile( aFileName );
126
127 try
128 {
129 // Parse File
131 pcb.Parse( altiumPcbFile, mapping );
132 }
133 catch( CFB::CFBException& exception )
134 {
135 THROW_IO_ERROR( exception.what() );
136 }
137
138 return m_board;
139}
void Parse(const ALTIUM_PCB_COMPOUND_FILE &aAltiumPcbFile, const std::map< ALTIUM_PCB_DIR, std::string > &aFileMapping)
Definition: altium_pcb.cpp:338
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
void SetFileName(const wxString &aFileName)
Definition: board.h:325
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
Definition: io_base.h:218
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
Definition: io_base.h:221
virtual void RegisterCallback(LAYER_MAPPING_HANDLER aLayerMappingHandler)
Register a different handler to be called when mapping of input layers to KiCad layers occurs.
LAYER_MAPPING_HANDLER m_layer_mapping_handler
Callback to get layer mapping.
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 std::map< std::string, UTF8 > *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:71
BOARD * m_board
The board BOARD being worked on, no ownership here.
Definition: pcb_io.h:342
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
Definition: pcb_io.cpp:42
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Definition: pcb_io.h:345
Container for project specific data.
Definition: project.h:64
static REPORTER & GetInstance()
Definition: reporter.cpp:199
static void SetReporter(REPORTER *aReporter)
Set the reporter to use for reporting font substitution warnings.
Definition: fontconfig.cpp:64
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:39