KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_altium_designer.h
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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef PCB_IO_ALTIUM_DESIGNER_H_
22#define PCB_IO_ALTIUM_DESIGNER_H_
23
24#include <pcb_io/pcb_io.h>
25#include <pcb_io/pcb_io_mgr.h>
27
28#include <map>
29#include <memory>
30#include <vector>
31
32enum class ALTIUM_PCB_DIR;
34class BOARD;
35class PROJECT;
37
43 const std::vector<ALTIUM_PROJECT_VARIANT>& aVariants );
44
45
46void LoadAltiumBoard( const wxString& aFileName, BOARD* aBoard,
47 const std::map<ALTIUM_PCB_DIR, std::string>& aMapping,
48 const std::map<std::string, UTF8>* aProperties, PROJECT* aProject,
49 PROGRESS_REPORTER* aProgressReporter, LAYER_MAPPING_HANDLER& aLayerMappingHandler,
50 REPORTER* aReporter );
51
52
54{
55public:
56 // -----<PUBLIC PCB_IO API>--------------------------------------------------
58 {
59 return IO_BASE::IO_FILE_DESC( _HKI( "Altium Designer PCB files" ), { "PcbDoc" } );
60 }
61
63 {
64 return IO_BASE::IO_FILE_DESC( _HKI( "Altium PCB Library or Integrated Library" ),
65 { "PcbLib", "IntLib" } );
66 }
67
68 bool CanReadBoard( const wxString& aFileName ) const override;
69 bool CanReadLibrary( const wxString& aFileName ) const override;
70
71 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
72
73 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
74 bool aBestEfforts, const std::map<std::string, UTF8>* aProperties = nullptr ) override;
75
76 std::unique_ptr<FOOTPRINT> FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
77 bool aKeepUUID = false,
78 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
79
80 std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints() override;
81
82 //bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = nullptr );
83
84 bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
85
86 // -----</PUBLIC PCB_IO API>-------------------------------------------------
87
90
91 static bool checkFileHeader( const wxString& aFileName );
92
99 static std::map<wxString, PCB_LAYER_ID> DefaultLayerMappingCallback(
100 const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector );
101
102protected:
103 void loadBoard( const wxString& aFileName, BOARD& aBoard, bool aIsNewLoad,
104 const std::map<std::string, UTF8>* aProperties, PROJECT* aProject = nullptr ) override;
105
106private:
108 {
109 std::vector<std::unique_ptr<ALTIUM_PCB_COMPOUND_FILE>> m_Files;
110 long long m_Timestamp;
111 };
112
113 std::map<wxString, ALTIUM_FILE_CACHE> m_fplibFiles;
114
115 void loadAltiumLibrary( const wxString& aLibraryPath );
116};
117
118#endif // PCB_IO_ALTIUM_DESIGNER_H_
ALTIUM_PCB_DIR
Definition altium_pcb.h:40
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
Plugin class for import plugins that support remappable layers.
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints() override
Return a container with the cached library footprints generated in the last call to Load.
static bool checkFileHeader(const wxString &aFileName)
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
Return board file description for the PCB_IO.
bool CanReadBoard(const wxString &aFileName) const override
std::unique_ptr< FOOTPRINT > FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
void loadAltiumLibrary(const wxString &aLibraryPath)
void loadBoard(const wxString &aFileName, BOARD &aBoard, bool aIsNewLoad, const std::map< std::string, UTF8 > *aProperties, PROJECT *aProject=nullptr) override
Parse aFileName into aBoard.
static std::map< wxString, PCB_LAYER_ID > DefaultLayerMappingCallback(const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
Return the automapped layers.
bool IsLibraryWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
std::map< wxString, ALTIUM_FILE_CACHE > m_fplibFiles
const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
PCB_IO(const wxString &aName)
Definition pcb_io.h:383
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
Definition project.h:63
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
#define _HKI(x)
Definition page_info.cpp:40
void ApplyAltiumProjectVariantsToBoard(BOARD *aBoard, const std::vector< ALTIUM_PROJECT_VARIANT > &aVariants)
Apply parsed Altium project variants to a board by setting FOOTPRINT_VARIANT data on each footprint w...
void LoadAltiumBoard(const wxString &aFileName, BOARD *aBoard, const std::map< ALTIUM_PCB_DIR, std::string > &aMapping, const std::map< std::string, UTF8 > *aProperties, PROJECT *aProject, PROGRESS_REPORTER *aProgressReporter, LAYER_MAPPING_HANDLER &aLayerMappingHandler, REPORTER *aReporter)
std::function< std::map< wxString, PCB_LAYER_ID >(const std::vector< INPUT_LAYER_DESC > &)> LAYER_MAPPING_HANDLER
Pointer to a function that takes a map of source and KiCad layers and returns a re-mapped version.
A project-level assembly variant parsed from an Altium .PrjPcb file.
Container that describes file type info.
Definition io_base.h:43
std::vector< std::unique_ptr< ALTIUM_PCB_COMPOUND_FILE > > m_Files