2020-04-03 23:22:24 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019-2020 Thomas Pointhuber <thomas.pointhuber@gmx.at>
|
2023-07-21 15:02:59 +00:00
|
|
|
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-04-03 23:22:24 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ALTIUM_PCB_H
|
|
|
|
#define ALTIUM_PCB_H
|
|
|
|
|
|
|
|
#include <functional>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2020-04-03 23:22:24 +00:00
|
|
|
#include <vector>
|
2024-05-08 22:36:02 +00:00
|
|
|
#include <pcb_io/common/plugin_common_layer_mapping.h>
|
|
|
|
|
2020-04-03 23:22:24 +00:00
|
|
|
|
|
|
|
#include <altium_parser_pcb.h>
|
|
|
|
|
|
|
|
|
|
|
|
enum class ALTIUM_PCB_DIR
|
|
|
|
{
|
|
|
|
FILE_HEADER,
|
|
|
|
|
|
|
|
ADVANCEDPLACEROPTIONS6,
|
|
|
|
ARCS6,
|
|
|
|
BOARD6,
|
|
|
|
BOARDREGIONS,
|
|
|
|
CLASSES6,
|
|
|
|
COMPONENTBODIES6,
|
|
|
|
COMPONENTS6,
|
|
|
|
CONNECTIONS6,
|
|
|
|
COORDINATES6,
|
|
|
|
DESIGNRULECHECKEROPTIONS6,
|
|
|
|
DIFFERENTIALPAIRS6,
|
|
|
|
DIMENSIONS6,
|
|
|
|
EMBEDDEDBOARDS6,
|
|
|
|
EMBEDDEDFONTS6,
|
|
|
|
EMBEDDEDS6,
|
|
|
|
EXTENDPRIMITIVEINFORMATION,
|
|
|
|
FILEVERSIONINFO,
|
|
|
|
FILLS6,
|
|
|
|
FROMTOS6,
|
|
|
|
MODELS,
|
|
|
|
MODELSNOEMBED,
|
|
|
|
NETS6,
|
|
|
|
PADS6,
|
|
|
|
PADVIALIBRARY,
|
|
|
|
PADVIALIBRARYCACHE,
|
|
|
|
PADVIALIBRARYLINKS,
|
|
|
|
PINSWAPOPTIONS6,
|
|
|
|
PINPAIRSSECTION,
|
|
|
|
POLYGONS6,
|
|
|
|
REGIONS6,
|
|
|
|
RULES6,
|
|
|
|
SHAPEBASEDCOMPONENTBODIES6,
|
|
|
|
SHAPEBASEDREGIONS6,
|
|
|
|
SIGNALCLASSES,
|
|
|
|
SMARTUNIONS,
|
|
|
|
TEXTS,
|
|
|
|
TEXTS6,
|
|
|
|
TEXTURES,
|
|
|
|
TRACKS6,
|
|
|
|
UNIONNAMES,
|
|
|
|
UNIQUEIDPRIMITIVEINFORMATION,
|
|
|
|
VIAS6,
|
|
|
|
WIDESTRINGS6
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BOARD;
|
2022-01-16 14:37:25 +00:00
|
|
|
class FP_SHAPE;
|
2020-10-04 23:34:59 +00:00
|
|
|
class PCB_SHAPE;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2020-11-11 23:05:59 +00:00
|
|
|
class ZONE;
|
2021-07-24 19:05:34 +00:00
|
|
|
class PCB_DIM_RADIAL;
|
2021-06-26 10:49:58 +00:00
|
|
|
class PROGRESS_REPORTER;
|
2020-04-03 23:22:24 +00:00
|
|
|
|
|
|
|
namespace CFB
|
|
|
|
{
|
|
|
|
struct COMPOUND_FILE_ENTRY;
|
|
|
|
} // namespace CFB
|
|
|
|
|
2022-01-06 15:27:09 +00:00
|
|
|
class ALTIUM_COMPOUND_FILE;
|
2020-04-03 23:22:24 +00:00
|
|
|
|
|
|
|
// type declaration required for a helper method
|
|
|
|
class ALTIUM_PCB;
|
2022-01-06 15:27:09 +00:00
|
|
|
typedef std::function<void( const ALTIUM_COMPOUND_FILE&, const CFB::COMPOUND_FILE_ENTRY* )>
|
2020-04-03 23:22:24 +00:00
|
|
|
PARSE_FUNCTION_POINTER_fp;
|
|
|
|
|
|
|
|
class ALTIUM_PCB
|
|
|
|
{
|
|
|
|
public:
|
2024-02-19 12:24:13 +00:00
|
|
|
explicit ALTIUM_PCB( BOARD* aBoard, PROGRESS_REPORTER* aProgressReporter,
|
2024-05-08 22:36:02 +00:00
|
|
|
LAYER_MAPPING_HANDLER& aLayerMappingHandler,
|
2024-05-01 01:21:48 +00:00
|
|
|
REPORTER* aReporter = nullptr,
|
2024-02-19 12:24:13 +00:00
|
|
|
const wxString& aLibrary = wxEmptyString,
|
|
|
|
const wxString& aFootprintName = wxEmptyString);
|
2020-04-03 23:22:24 +00:00
|
|
|
~ALTIUM_PCB();
|
|
|
|
|
2022-01-06 15:27:09 +00:00
|
|
|
void Parse( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
2021-07-24 13:23:55 +00:00
|
|
|
const std::map<ALTIUM_PCB_DIR, std::string>& aFileMapping );
|
2020-04-03 23:22:24 +00:00
|
|
|
|
2023-08-31 16:16:35 +00:00
|
|
|
FOOTPRINT* ParseFootprint( ALTIUM_COMPOUND_FILE& altiumLibFile,
|
2022-01-10 13:31:23 +00:00
|
|
|
const wxString& aFootprintName );
|
|
|
|
|
2020-04-03 23:22:24 +00:00
|
|
|
private:
|
2021-06-26 10:49:58 +00:00
|
|
|
void checkpoint();
|
|
|
|
|
2020-04-03 23:22:24 +00:00
|
|
|
PCB_LAYER_ID GetKicadLayer( ALTIUM_LAYER aAltiumLayer ) const;
|
2022-01-10 16:45:37 +00:00
|
|
|
std::vector<PCB_LAYER_ID> GetKicadLayersToIterate( ALTIUM_LAYER aAltiumLayer ) const;
|
2020-04-03 23:22:24 +00:00
|
|
|
int GetNetCode( uint16_t aId ) const;
|
|
|
|
const ARULE6* GetRule( ALTIUM_RULE_KIND aKind, const wxString& aName ) const;
|
|
|
|
const ARULE6* GetRuleDefault( ALTIUM_RULE_KIND aKind ) const;
|
|
|
|
|
2022-01-06 15:27:09 +00:00
|
|
|
void ParseFileHeader( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
2020-04-03 23:22:24 +00:00
|
|
|
|
|
|
|
// Text Format
|
2022-01-06 15:27:09 +00:00
|
|
|
void ParseBoard6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
|
|
|
void ParseClasses6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
|
|
|
void ParseComponents6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
|
|
|
void ParseDimensions6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
|
|
|
void ParseModelsData( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
2022-02-19 15:45:55 +00:00
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry,
|
|
|
|
const std::vector<std::string>& aRootDir );
|
2022-01-06 15:27:09 +00:00
|
|
|
void ParseNets6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
|
|
|
void ParsePolygons6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
|
|
|
void ParseRules6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
2020-04-03 23:22:24 +00:00
|
|
|
|
|
|
|
// Binary Format
|
2022-01-06 15:27:09 +00:00
|
|
|
void ParseArcs6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
2022-01-10 19:45:42 +00:00
|
|
|
void ConvertArcs6ToPcbShape( const AARC6& aElem, PCB_SHAPE* aShape );
|
2022-02-20 19:18:22 +00:00
|
|
|
void ConvertArcs6ToBoardItem( const AARC6& aElem, const int aPrimitiveIndex );
|
2022-01-10 19:45:42 +00:00
|
|
|
void ConvertArcs6ToFootprintItem( FOOTPRINT* aFootprint, const AARC6& aElem,
|
2022-02-20 19:18:22 +00:00
|
|
|
const int aPrimitiveIndex, const bool aIsBoardImport );
|
2022-01-10 19:45:42 +00:00
|
|
|
void ConvertArcs6ToBoardItemOnLayer( const AARC6& aElem, PCB_LAYER_ID aLayer );
|
|
|
|
void ConvertArcs6ToFootprintItemOnLayer( FOOTPRINT* aFootprint, const AARC6& aElem,
|
|
|
|
PCB_LAYER_ID aLayer );
|
2022-01-06 15:27:09 +00:00
|
|
|
void ParseComponentsBodies6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
|
|
|
void ParsePads6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
2022-01-16 14:37:25 +00:00
|
|
|
void ConvertPads6ToBoardItem( const APAD6& aElem );
|
|
|
|
void ConvertPads6ToFootprintItem( FOOTPRINT* aFootprint, const APAD6& aElem );
|
|
|
|
void ConvertPads6ToBoardItemOnNonCopper( const APAD6& aElem );
|
|
|
|
void ConvertPads6ToFootprintItemOnCopper( FOOTPRINT* aFootprint, const APAD6& aElem );
|
|
|
|
void ConvertPads6ToFootprintItemOnNonCopper( FOOTPRINT* aFootprint, const APAD6& aElem );
|
2022-01-06 15:27:09 +00:00
|
|
|
void ParseVias6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
2024-06-14 23:48:41 +00:00
|
|
|
void ConvertVias6ToFootprintItem( FOOTPRINT* aFootprint, const AVIA6& aElem );
|
2022-01-06 15:27:09 +00:00
|
|
|
void ParseTracks6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
2022-02-20 19:18:22 +00:00
|
|
|
void ConvertTracks6ToBoardItem( const ATRACK6& aElem, const int aPrimitiveIndex );
|
2022-01-10 19:45:42 +00:00
|
|
|
void ConvertTracks6ToFootprintItem( FOOTPRINT* aFootprint, const ATRACK6& aElem,
|
2022-02-20 19:18:22 +00:00
|
|
|
const int aPrimitiveIndex, const bool aIsBoardImport );
|
2022-01-10 19:45:42 +00:00
|
|
|
void ConvertTracks6ToBoardItemOnLayer( const ATRACK6& aElem, PCB_LAYER_ID aLayer );
|
|
|
|
void ConvertTracks6ToFootprintItemOnLayer( FOOTPRINT* aFootprint, const ATRACK6& aElem,
|
|
|
|
PCB_LAYER_ID aLayer );
|
2022-01-06 15:27:09 +00:00
|
|
|
void ParseTexts6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
2022-01-16 13:40:23 +00:00
|
|
|
void ConvertTexts6ToBoardItem( const ATEXT6& aElem );
|
|
|
|
void ConvertTexts6ToFootprintItem( FOOTPRINT* aFootprint, const ATEXT6& aElem );
|
|
|
|
void ConvertTexts6ToBoardItemOnLayer( const ATEXT6& aElem, PCB_LAYER_ID aLayer );
|
|
|
|
void ConvertTexts6ToFootprintItemOnLayer( FOOTPRINT* aFootprint, const ATEXT6& aElem,
|
|
|
|
PCB_LAYER_ID aLayer );
|
2024-03-30 23:03:03 +00:00
|
|
|
void ConvertTexts6ToEdaTextSettings( const ATEXT6& aElem, EDA_TEXT& aEdaText );
|
2022-01-06 15:27:09 +00:00
|
|
|
void ParseFills6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
2022-01-17 18:49:06 +00:00
|
|
|
void ConvertFills6ToBoardItem( const AFILL6& aElem );
|
|
|
|
void ConvertFills6ToFootprintItem( FOOTPRINT* aFootprint, const AFILL6& aElem,
|
|
|
|
const bool aIsBoardImport );
|
|
|
|
void ConvertFills6ToBoardItemOnLayer( const AFILL6& aElem, PCB_LAYER_ID aLayer );
|
|
|
|
void ConvertFills6ToFootprintItemOnLayer( FOOTPRINT* aFootprint, const AFILL6& aElem,
|
|
|
|
PCB_LAYER_ID aLayer );
|
2022-01-06 15:27:09 +00:00
|
|
|
void ParseBoardRegionsData( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
|
|
|
void ParseShapeBasedRegions6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
2022-01-25 20:53:42 +00:00
|
|
|
void ConvertShapeBasedRegions6ToBoardItem( const AREGION6& aElem );
|
2023-07-21 15:02:59 +00:00
|
|
|
void ConvertShapeBasedRegions6ToFootprintItem( FOOTPRINT* aFootprint, const AREGION6& aElem,
|
|
|
|
const int aPrimitiveIndex );
|
2022-01-25 20:53:42 +00:00
|
|
|
void ConvertShapeBasedRegions6ToBoardItemOnLayer( const AREGION6& aElem, PCB_LAYER_ID aLayer );
|
|
|
|
void ConvertShapeBasedRegions6ToFootprintItemOnLayer( FOOTPRINT* aFootprint,
|
|
|
|
const AREGION6& aElem,
|
2023-07-21 15:02:59 +00:00
|
|
|
PCB_LAYER_ID aLayer,
|
|
|
|
const int aPrimitiveIndex );
|
2022-02-20 19:18:22 +00:00
|
|
|
void ParseExtendedPrimitiveInformationData( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
2022-01-06 15:27:09 +00:00
|
|
|
void ParseRegions6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
|
|
|
void ParseWideStrings6Data( const ALTIUM_COMPOUND_FILE& aAltiumPcbFile,
|
|
|
|
const CFB::COMPOUND_FILE_ENTRY* aEntry );
|
2020-04-03 23:22:24 +00:00
|
|
|
|
|
|
|
// Helper Functions
|
|
|
|
void HelperParseDimensions6Linear( const ADIMENSION6& aElem );
|
2021-07-24 13:23:55 +00:00
|
|
|
void HelperParseDimensions6Radial( const ADIMENSION6& aElem );
|
2020-04-03 23:22:24 +00:00
|
|
|
void HelperParseDimensions6Leader( const ADIMENSION6& aElem );
|
|
|
|
void HelperParseDimensions6Datum( const ADIMENSION6& aElem );
|
|
|
|
void HelperParseDimensions6Center( const ADIMENSION6& aElem );
|
|
|
|
|
2022-01-16 14:37:25 +00:00
|
|
|
void HelperParsePad6NonCopper( const APAD6& aElem, PCB_LAYER_ID aLayer, PCB_SHAPE* aShape );
|
2020-04-18 21:47:53 +00:00
|
|
|
|
2020-04-03 23:22:24 +00:00
|
|
|
void HelperCreateBoardOutline( const std::vector<ALTIUM_VERTICE>& aVertices );
|
|
|
|
|
2024-03-30 23:03:03 +00:00
|
|
|
void HelperSetZoneLayers( ZONE& aZone, const ALTIUM_LAYER aAltiumLayer );
|
|
|
|
void HelperSetZoneKeepoutRestrictions( ZONE& aZone, const uint8_t aKeepoutRestrictions );
|
2022-03-07 18:58:43 +00:00
|
|
|
void HelperPcpShapeAsBoardKeepoutRegion( const PCB_SHAPE& aShape,
|
|
|
|
const ALTIUM_LAYER aAltiumLayer,
|
2022-03-11 18:15:34 +00:00
|
|
|
const uint8_t aKeepoutRestrictions );
|
2022-01-10 16:45:37 +00:00
|
|
|
void HelperPcpShapeAsFootprintKeepoutRegion( FOOTPRINT* aFootprint, const PCB_SHAPE& aShape,
|
2022-03-07 18:58:43 +00:00
|
|
|
const ALTIUM_LAYER aAltiumLayer,
|
2022-03-11 18:15:34 +00:00
|
|
|
const uint8_t aKeepoutRestrictions );
|
2022-01-10 16:45:37 +00:00
|
|
|
|
2022-02-20 19:18:22 +00:00
|
|
|
std::vector<std::pair<PCB_LAYER_ID, int>>
|
|
|
|
HelperGetSolderAndPasteMaskExpansions( const ALTIUM_RECORD aType, const int aPrimitiveIndex,
|
|
|
|
const ALTIUM_LAYER aAltiumLayer );
|
|
|
|
|
2022-01-10 16:45:37 +00:00
|
|
|
FOOTPRINT* HelperGetFootprint( uint16_t aComponent ) const;
|
2020-04-18 21:47:53 +00:00
|
|
|
|
2024-05-08 22:36:02 +00:00
|
|
|
void remapUnsureLayers( std::vector<ABOARD6_LAYER_STACKUP>& aStackup );
|
|
|
|
|
2020-04-03 23:22:24 +00:00
|
|
|
BOARD* m_board;
|
2020-11-13 15:15:52 +00:00
|
|
|
std::vector<FOOTPRINT*> m_components;
|
2020-11-11 23:05:59 +00:00
|
|
|
std::vector<ZONE*> m_polygons;
|
2021-07-24 19:05:34 +00:00
|
|
|
std::vector<PCB_DIM_RADIAL*> m_radialDimensions;
|
2020-04-21 13:34:06 +00:00
|
|
|
std::map<wxString, wxString> m_models;
|
2021-11-10 16:46:01 +00:00
|
|
|
std::map<uint32_t, wxString> m_unicodeStrings;
|
2022-11-19 11:50:54 +00:00
|
|
|
std::vector<int> m_altiumToKicadNetcodes;
|
2020-04-03 23:22:24 +00:00
|
|
|
std::map<ALTIUM_LAYER, PCB_LAYER_ID> m_layermap; // used to correctly map copper layers
|
2024-05-08 22:36:02 +00:00
|
|
|
std::map<ALTIUM_LAYER, wxString> m_layerNames;
|
2020-04-03 23:22:24 +00:00
|
|
|
std::map<ALTIUM_RULE_KIND, std::vector<ARULE6>> m_rules;
|
2022-02-20 19:18:22 +00:00
|
|
|
std::map<ALTIUM_RECORD, std::multimap<int, const AEXTENDED_PRIMITIVE_INFORMATION>>
|
|
|
|
m_extendedPrimitiveInformationMaps;
|
2020-04-03 23:22:24 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
std::map<ALTIUM_LAYER, ZONE*> m_outer_plane;
|
2020-05-10 17:30:03 +00:00
|
|
|
|
2024-05-08 22:36:02 +00:00
|
|
|
LAYER_MAPPING_HANDLER m_layerMappingHandler;
|
|
|
|
|
2024-02-19 12:24:13 +00:00
|
|
|
PROGRESS_REPORTER* m_progressReporter; ///< optional; may be nullptr
|
2024-05-01 01:21:48 +00:00
|
|
|
REPORTER* m_reporter; ///< optional; may be nullptr
|
2021-06-26 10:49:58 +00:00
|
|
|
unsigned m_doneCount;
|
|
|
|
unsigned m_lastProgressCount;
|
2024-02-19 12:24:13 +00:00
|
|
|
unsigned m_totalCount; ///< for progress reporting
|
|
|
|
|
|
|
|
wxString m_library; ///< for footprint library loading error reporting
|
|
|
|
wxString m_footprintName; ///< for footprint library loading error reporting
|
2021-06-26 10:49:58 +00:00
|
|
|
|
2020-05-10 17:30:03 +00:00
|
|
|
/// Altium stores pour order across all layers
|
|
|
|
int m_highest_pour_index;
|
2020-04-03 23:22:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //ALTIUM_PCB_H
|