KiCad PCB EDA Suite
altium_pcb.h File Reference
#include <functional>
#include <layers_id_colors_and_visibility.h>
#include <vector>
#include <altium_parser_pcb.h>

Go to the source code of this file.

Classes

class  ALTIUM_PCB
 

Namespaces

 CFB
 

Typedefs

typedef std::function< void(const CFB::CompoundFileReader &, const CFB::COMPOUND_FILE_ENTRY *)> PARSE_FUNCTION_POINTER_fp
 

Enumerations

enum  ALTIUM_PCB_DIR {
  ALTIUM_PCB_DIR::FILE_HEADER, ALTIUM_PCB_DIR::ADVANCEDPLACEROPTIONS6, ALTIUM_PCB_DIR::ARCS6, ALTIUM_PCB_DIR::BOARD6,
  ALTIUM_PCB_DIR::BOARDREGIONS, ALTIUM_PCB_DIR::CLASSES6, ALTIUM_PCB_DIR::COMPONENTBODIES6, ALTIUM_PCB_DIR::COMPONENTS6,
  ALTIUM_PCB_DIR::CONNECTIONS6, ALTIUM_PCB_DIR::COORDINATES6, ALTIUM_PCB_DIR::DESIGNRULECHECKEROPTIONS6, ALTIUM_PCB_DIR::DIFFERENTIALPAIRS6,
  ALTIUM_PCB_DIR::DIMENSIONS6, ALTIUM_PCB_DIR::EMBEDDEDBOARDS6, ALTIUM_PCB_DIR::EMBEDDEDFONTS6, ALTIUM_PCB_DIR::EMBEDDEDS6,
  ALTIUM_PCB_DIR::EXTENDPRIMITIVEINFORMATION, ALTIUM_PCB_DIR::FILEVERSIONINFO, ALTIUM_PCB_DIR::FILLS6, ALTIUM_PCB_DIR::FROMTOS6,
  ALTIUM_PCB_DIR::MODELS, ALTIUM_PCB_DIR::MODELSNOEMBED, ALTIUM_PCB_DIR::NETS6, ALTIUM_PCB_DIR::PADS6,
  ALTIUM_PCB_DIR::PADVIALIBRARY, ALTIUM_PCB_DIR::PADVIALIBRARYCACHE, ALTIUM_PCB_DIR::PADVIALIBRARYLINKS, ALTIUM_PCB_DIR::PINSWAPOPTIONS6,
  ALTIUM_PCB_DIR::PINPAIRSSECTION, ALTIUM_PCB_DIR::POLYGONS6, ALTIUM_PCB_DIR::REGIONS6, ALTIUM_PCB_DIR::RULES6,
  ALTIUM_PCB_DIR::SHAPEBASEDCOMPONENTBODIES6, ALTIUM_PCB_DIR::SHAPEBASEDREGIONS6, ALTIUM_PCB_DIR::SIGNALCLASSES, ALTIUM_PCB_DIR::SMARTUNIONS,
  ALTIUM_PCB_DIR::TEXTS, ALTIUM_PCB_DIR::TEXTS6, ALTIUM_PCB_DIR::TEXTURES, ALTIUM_PCB_DIR::TRACKS6,
  ALTIUM_PCB_DIR::UNIONNAMES, ALTIUM_PCB_DIR::UNIQUEIDPRIMITIVEINFORMATION, ALTIUM_PCB_DIR::VIAS6, ALTIUM_PCB_DIR::WIDESTRINGS6
}
 

Functions

void ParseAltiumPcb (BOARD *aBoard, const wxString &aFileName, const std::map< ALTIUM_PCB_DIR, std::string > &aFileMapping)
 Helper method which opens a Altium Board File and parses it. More...
 

Typedef Documentation

◆ PARSE_FUNCTION_POINTER_fp

typedef std::function<void( const CFB::CompoundFileReader&, const CFB::COMPOUND_FILE_ENTRY* )> PARSE_FUNCTION_POINTER_fp

Definition at line 109 of file altium_pcb.h.

Enumeration Type Documentation

◆ ALTIUM_PCB_DIR

enum ALTIUM_PCB_DIR
strong
Enumerator
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 

Definition at line 34 of file altium_pcb.h.

35 {
37 
39  ARCS6,
40  BOARD6,
42  CLASSES6,
52  EMBEDDEDS6,
55  FILLS6,
56  FROMTOS6,
57  MODELS,
59  NETS6,
60  PADS6,
66  POLYGONS6,
67  REGIONS6,
68  RULES6,
73  TEXTS,
74  TEXTS6,
75  TEXTURES,
76  TRACKS6,
77  UNIONNAMES,
79  VIAS6,
81 };

Function Documentation

◆ ParseAltiumPcb()

void ParseAltiumPcb ( BOARD aBoard,
const wxString &  aFileName,
const std::map< ALTIUM_PCB_DIR, std::string > &  aFileMapping 
)

Helper method which opens a Altium Board File and parses it.

Parameters
aBoardboard the pcb should be appended to
aFileNamefile name of board file
aFileMappingmapping how altium stream names are mapped

Definition at line 50 of file altium_pcb.cpp.

52 {
53  // Open file
54  FILE* fp = wxFopen( aFileName, "rb" );
55  if( fp == nullptr )
56  {
57  wxLogError( wxString::Format( _( "Cannot open file '%s'" ), aFileName ) );
58  return;
59  }
60 
61  fseek( fp, 0, SEEK_END );
62  long len = ftell( fp );
63  if( len < 0 )
64  {
65  fclose( fp );
66  THROW_IO_ERROR( "Reading error, cannot determine length of file" );
67  }
68 
69  std::unique_ptr<unsigned char[]> buffer( new unsigned char[len] );
70  fseek( fp, 0, SEEK_SET );
71 
72  size_t bytesRead = fread( buffer.get(), sizeof( unsigned char ), len, fp );
73  fclose( fp );
74  if( static_cast<size_t>( len ) != bytesRead )
75  {
76  THROW_IO_ERROR( "Reading error" );
77  }
78 
79  try
80  {
81  CFB::CompoundFileReader reader( buffer.get(), bytesRead );
82 
83  // Parse File
84  ALTIUM_PCB pcb( aBoard );
85  pcb.Parse( reader, aFileMapping );
86  }
87  catch( CFB::CFBException& exception )
88  {
89  THROW_IO_ERROR( exception.what() );
90  }
91 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
#define _(s)
Definition: 3d_actions.cpp:33
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), and THROW_IO_ERROR.

Referenced by ALTIUM_CIRCUIT_MAKER_PLUGIN::Load(), ALTIUM_DESIGNER_PLUGIN::Load(), and ALTIUM_CIRCUIT_STUDIO_PLUGIN::Load().