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
54 const std::map<wxString, wxString>& aParameters );
55
56
57void LoadAltiumBoard( const wxString& aFileName, BOARD* aBoard,
58 const std::map<ALTIUM_PCB_DIR, std::string>& aMapping,
59 const std::map<std::string, UTF8>* aProperties, PROJECT* aProject,
60 PROGRESS_REPORTER* aProgressReporter, LAYER_MAPPING_HANDLER& aLayerMappingHandler,
61 REPORTER* aReporter );
62
63
65{
66public:
67 // -----<PUBLIC PCB_IO API>--------------------------------------------------
69 {
70 return IO_BASE::IO_FILE_DESC( _HKI( "Altium Designer PCB files" ), { "PcbDoc" } );
71 }
72
74 {
75 return IO_BASE::IO_FILE_DESC( _HKI( "Altium PCB Library or Integrated Library" ),
76 { "PcbLib", "IntLib" } );
77 }
78
79 bool CanReadBoard( const wxString& aFileName ) const override;
80 bool CanReadLibrary( const wxString& aFileName ) const override;
81
82 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
83
84 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
85 bool aBestEfforts, const std::map<std::string, UTF8>* aProperties = nullptr ) override;
86
87 std::unique_ptr<FOOTPRINT> FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
88 bool aKeepUUID = false,
89 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
90
91 std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints() override;
92
93 //bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = nullptr );
94
95 bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
96
97 // -----</PUBLIC PCB_IO API>-------------------------------------------------
98
101
102 static bool checkFileHeader( const wxString& aFileName );
103
110 static std::map<wxString, PCB_LAYER_ID> DefaultLayerMappingCallback(
111 const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector );
112
113protected:
114 void loadBoard( const wxString& aFileName, BOARD& aBoard, bool aIsNewLoad,
115 const std::map<std::string, UTF8>* aProperties, PROJECT* aProject = nullptr ) override;
116
117private:
119 {
120 std::vector<std::unique_ptr<ALTIUM_PCB_COMPOUND_FILE>> m_Files;
121 long long m_Timestamp;
122 };
123
124 std::map<wxString, ALTIUM_FILE_CACHE> m_fplibFiles;
125
126 void loadAltiumLibrary( const wxString& aLibraryPath );
127};
128
129#endif // PCB_IO_ALTIUM_DESIGNER_H_
ALTIUM_PCB_DIR
Definition altium_pcb.h:38
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:410
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:372
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)
void ApplyAltiumProjectParametersToProject(PROJECT *aProject, const std::map< wxString, wxString > &aParameters)
Register Altium project parameters as KiCad project text variables so that imported board text refere...
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