KiCad PCB EDA Suite
Loading...
Searching...
No Matches
allegro_builder.cpp File Reference
#include "allegro_builder.h"
#include <chrono>
#include <cmath>
#include <limits>
#include <set>
#include <tuple>
#include <unordered_set>
#include <convert/allegro_pcb_structs.h>
#include <wx/log.h>
#include <core/profile.h>
#include <board_design_settings.h>
#include <project/net_settings.h>
#include <footprint.h>
#include <netclass.h>
#include <pad.h>
#include <pcb_text.h>
#include <pcb_shape.h>
#include <pcb_track.h>
#include <zone.h>
#include <convert_basic_shapes_to_polygon.h>

Go to the source code of this file.

Classes

class  LL_WALKER
 
class  LL_WALKER::iterator
 
struct  std::hash< LAYER_INFO >
 
class  ALLEGRO::LAYER_MAPPER
 Class to handle the mapping for Allegro CLASS/SUBCLASS idiom to KiCad layers. More...
 
struct  ALLEGRO::LAYER_MAPPER::CUSTOM_LAYER
 Represents the information found in a single entry of a layer list. More...
 

Macros

#define BLK_FIELD(BLK_T, FIELD)
 

Functions

static uint32_t GetPrimaryNext (const BLOCK_BASE &aBlock)
 Gets the next block in the linked list.
 
static uint32_t PadGetNextInFootprint (const BLOCK_BASE &aBlock)
 "Get Next" function for the pad list in a footprint's 0x32 list.
 
static wxString layerInfoDisplayName (const LAYER_INFO &aLayerInfo)
 Build a unique display name for a LAYER_INFO entry from the static maps above, suitable for presentation in the layer mapping dialog.
 
static int safeScale (double aValue)
 

Variables

static const wxChar *const traceAllegroBuilder = wxT( "KICAD_ALLEGRO_BUILDER" )
 Flag to enable debug output of Allegro board construction.
 
static const wxChar *const traceAllegroPerf = wxT( "KICAD_ALLEGRO_PERF" )
 
static const std::unordered_map< LAYER_INFO, PCB_LAYER_IDs_LayerKiMap
 Map of the pre-set class:subclass pairs to standard layers.
 
static const std::unordered_map< LAYER_INFO, wxString > s_OptionalFixedMappings
 Names for custom KiCad layers that correspond to pre-defined Allegro layers.
 

Macro Definition Documentation

◆ BLK_FIELD

#define BLK_FIELD ( BLK_T,
FIELD )
Value:
static_cast<const BLOCK<BLK_T>&>( aBlock ).GetData().FIELD

Definition at line 66 of file allegro_builder.cpp.

Referenced by GetPrimaryNext(), and PadGetNextInFootprint().

Function Documentation

◆ GetPrimaryNext()

static uint32_t GetPrimaryNext ( const BLOCK_BASE & aBlock)
static

Gets the next block in the linked list.

Exactly which member does this depends on the block type.

It's not yet clear if any blocks can be in multiple linked lists at once - for now just follow the "main" one. This is done as dispatch like this to avoid forcing all the blocks into an inheritance hierarchy.

Parameters
aBlockThe block to get the next block from.
Returns
The next block in the linked list, or 0 if there is no next block.

Definition at line 79 of file allegro_builder.cpp.

References BLK_FIELD, and ALLEGRO::BLOCK_BASE::GetBlockType().

Referenced by LL_WALKER::LL_WALKER().

◆ layerInfoDisplayName()

static wxString layerInfoDisplayName ( const LAYER_INFO & aLayerInfo)
static

Build a unique display name for a LAYER_INFO entry from the static maps above, suitable for presentation in the layer mapping dialog.

Refer to https://www.artwork.com/all2dxf/alleggeo.htm for layer orders.

Definition at line 302 of file allegro_builder.cpp.

References ALLEGRO::LAYER_INFO::ANALYSIS, ALLEGRO::LAYER_INFO::ANALYSIS_HIGH_ISOCONTOUR, ALLEGRO::LAYER_INFO::ANALYSIS_LOW_ISOCONTOUR, ALLEGRO::LAYER_INFO::ANALYSIS_MEDIUM1_ISOCONTOUR, ALLEGRO::LAYER_INFO::ANALYSIS_MEDIUM2_ISOCONTOUR, ALLEGRO::LAYER_INFO::ANALYSIS_MEDIUM3_ISOCONTOUR, ALLEGRO::LAYER_INFO::ANALYSIS_PCB_TEMPERATURE, ALLEGRO::LAYER_INFO::ANTI_ETCH, ALLEGRO::LAYER_INFO::ASSEMBLY_BOTTOM, ALLEGRO::LAYER_INFO::ASSEMBLY_TOP, ALLEGRO::LAYER_INFO::BGEOM_ASSEMBLY_DETAIL, ALLEGRO::LAYER_INFO::BGEOM_ASSEMBLY_NOTES, ALLEGRO::LAYER_INFO::BGEOM_BOTH_ROOMS, ALLEGRO::LAYER_INFO::BGEOM_BOTTOM_ROOM, ALLEGRO::LAYER_INFO::BGEOM_CONSTRAINT_AREA, ALLEGRO::LAYER_INFO::BGEOM_DIMENSION, ALLEGRO::LAYER_INFO::BGEOM_OFF_GRID_AREA, ALLEGRO::LAYER_INFO::BGEOM_OUTLINE, ALLEGRO::LAYER_INFO::BGEOM_PLACE_GRID_BOTTOM, ALLEGRO::LAYER_INFO::BGEOM_PLACE_GRID_TOP, ALLEGRO::LAYER_INFO::BGEOM_PLATING_BAR, ALLEGRO::LAYER_INFO::BGEOM_SILKSCREEN_BOTTOM, ALLEGRO::LAYER_INFO::BGEOM_SILKSCREEN_TOP, ALLEGRO::LAYER_INFO::BGEOM_SOLDERMASK_BOTTOM, ALLEGRO::LAYER_INFO::BGEOM_SOLDERMASK_TOP, ALLEGRO::LAYER_INFO::BGEOM_SWITCH_AREA_BOTTOM, ALLEGRO::LAYER_INFO::BGEOM_SWITCH_AREA_TOP, ALLEGRO::LAYER_INFO::BGEOM_TOOLING_CORNERS, ALLEGRO::LAYER_INFO::BGEOM_TOP_ROOM, ALLEGRO::LAYER_INFO::BOARD_GEOMETRY, ALLEGRO::LAYER_INFO::BOUNDARY, ALLEGRO::LAYER_INFO::COMPONENT_VALUE, ALLEGRO::LAYER_INFO::DEVICE_TYPE, ALLEGRO::LAYER_INFO::DFA_BOUND_BOTTOM, ALLEGRO::LAYER_INFO::DFA_BOUND_TOP, ALLEGRO::LAYER_INFO::DFMT_OUTLINE, ALLEGRO::LAYER_INFO::DFMT_REVISION_BLOCK, ALLEGRO::LAYER_INFO::DFMT_REVISION_DATA, ALLEGRO::LAYER_INFO::DFMT_TITLE_BLOCK, ALLEGRO::LAYER_INFO::DFMT_TITLE_DATA, ALLEGRO::LAYER_INFO::DISPLAY_BOTTOM, ALLEGRO::LAYER_INFO::DISPLAY_TOP, ALLEGRO::LAYER_INFO::DRAWING_FORMAT, ALLEGRO::LAYER_INFO::ETCH, ALLEGRO::LAYER_INFO::m_Class, ALLEGRO::LAYER_INFO::m_Subclass, ALLEGRO::LAYER_INFO::MANUFACTURING, ALLEGRO::LAYER_INFO::MFR_AUTOSILK_BOTTOM, ALLEGRO::LAYER_INFO::MFR_AUTOSILK_TOP, ALLEGRO::LAYER_INFO::MFR_NCDRILL_FIGURE, ALLEGRO::LAYER_INFO::MFR_NCDRILL_LEGEND, ALLEGRO::LAYER_INFO::MFR_NO_GLOSS_ALL, ALLEGRO::LAYER_INFO::MFR_NO_GLOSS_BOTTOM, ALLEGRO::LAYER_INFO::MFR_NO_GLOSS_INTERNAL, ALLEGRO::LAYER_INFO::MFR_NO_GLOSS_TOP, ALLEGRO::LAYER_INFO::MFR_NO_PROBE_BOTTOM, ALLEGRO::LAYER_INFO::MFR_NO_PROBE_TOP, ALLEGRO::LAYER_INFO::MFR_PHOTOPLOT_OUTLINE, ALLEGRO::LAYER_INFO::MFR_PROBE_BOTTOM, ALLEGRO::LAYER_INFO::MFR_PROBE_TOP, ALLEGRO::LAYER_INFO::PACKAGE_GEOMETRY, ALLEGRO::LAYER_INFO::PACKAGE_KEEPIN, ALLEGRO::LAYER_INFO::PACKAGE_KEEPOUT, ALLEGRO::LAYER_INFO::PGEOM_ASSEMBLY_BOTTOM, ALLEGRO::LAYER_INFO::PGEOM_ASSEMBLY_TOP, ALLEGRO::LAYER_INFO::PGEOM_BODY_CENTER, ALLEGRO::LAYER_INFO::PGEOM_DISPLAY_BOTTOM, ALLEGRO::LAYER_INFO::PGEOM_DISPLAY_TOP, ALLEGRO::LAYER_INFO::PGEOM_PAD_STACK_NAME, ALLEGRO::LAYER_INFO::PGEOM_PIN_NUMBER, ALLEGRO::LAYER_INFO::PGEOM_PLACE_BOUND_BOTTOM, ALLEGRO::LAYER_INFO::PGEOM_PLACE_BOUND_TOP, ALLEGRO::LAYER_INFO::PGEOM_SILKSCREEN_BOTTOM, ALLEGRO::LAYER_INFO::PGEOM_SILKSCREEN_TOP, ALLEGRO::LAYER_INFO::PGEOM_SOLDERMASK_BOTTOM, ALLEGRO::LAYER_INFO::PGEOM_SOLDERMASK_TOP, ALLEGRO::LAYER_INFO::PIN, ALLEGRO::LAYER_INFO::REF_DES, ALLEGRO::LAYER_INFO::ROUTE_KEEPIN, ALLEGRO::LAYER_INFO::ROUTE_KEEPOUT, ALLEGRO::LAYER_INFO::SILKSCREEN_BOTTOM, ALLEGRO::LAYER_INFO::SILKSCREEN_TOP, ALLEGRO::LAYER_INFO::TOLERANCE, ALLEGRO::LAYER_INFO::USER_PART_NUMBER, ALLEGRO::LAYER_INFO::VIA_CLASS, and ALLEGRO::LAYER_INFO::VIA_KEEPOUT.

Referenced by ALLEGRO::BOARD_BUILDER::buildFootprint(), and ALLEGRO::LAYER_MAPPER::FinalizeLayers().

◆ PadGetNextInFootprint()

static uint32_t PadGetNextInFootprint ( const BLOCK_BASE & aBlock)
static

"Get Next" function for the pad list in a footprint's 0x32 list.

Definition at line 115 of file allegro_builder.cpp.

References BLK_FIELD, ALLEGRO::BLOCK_BASE::GetBlockType(), ALLEGRO::BLOCK_BASE::GetKey(), ALLEGRO::BLOCK_BASE::GetOffset(), and THROW_IO_ERROR.

Referenced by ALLEGRO::BOARD_BUILDER::buildFootprint().

◆ safeScale()

Variable Documentation

◆ s_LayerKiMap

const std::unordered_map<LAYER_INFO, PCB_LAYER_ID> s_LayerKiMap
static
Initial value:
= {
{ { LAYER_INFO::CLASS::COMPONENT_VALUE, LAYER_INFO::SUBCLASS::ASSEMBLY_BOTTOM}, B_Fab},
{ { LAYER_INFO::CLASS::COMPONENT_VALUE, LAYER_INFO::SUBCLASS::ASSEMBLY_TOP}, F_Fab},
{ { LAYER_INFO::CLASS::DEVICE_TYPE, LAYER_INFO::SUBCLASS::ASSEMBLY_BOTTOM}, B_Fab},
{ { LAYER_INFO::CLASS::DEVICE_TYPE, LAYER_INFO::SUBCLASS::ASSEMBLY_TOP}, F_Fab},
{ { LAYER_INFO::CLASS::PACKAGE_GEOMETRY, LAYER_INFO::SUBCLASS::PGEOM_SILKSCREEN_BOTTOM}, B_SilkS},
{ { LAYER_INFO::CLASS::PACKAGE_GEOMETRY, LAYER_INFO::SUBCLASS::PGEOM_SILKSCREEN_TOP}, F_SilkS},
{ { LAYER_INFO::CLASS::PACKAGE_GEOMETRY, LAYER_INFO::SUBCLASS::PGEOM_ASSEMBLY_BOTTOM}, B_Fab},
{ { LAYER_INFO::CLASS::PACKAGE_GEOMETRY, LAYER_INFO::SUBCLASS::PGEOM_ASSEMBLY_TOP}, F_Fab},
{ { LAYER_INFO::CLASS::PACKAGE_GEOMETRY, LAYER_INFO::SUBCLASS::PGEOM_PLACE_BOUND_BOTTOM}, B_CrtYd},
{ { LAYER_INFO::CLASS::PACKAGE_GEOMETRY, LAYER_INFO::SUBCLASS::PGEOM_PLACE_BOUND_TOP}, F_CrtYd},
{ { LAYER_INFO::CLASS::REF_DES, LAYER_INFO::SUBCLASS::SILKSCREEN_BOTTOM}, B_SilkS},
{ { LAYER_INFO::CLASS::REF_DES, LAYER_INFO::SUBCLASS::SILKSCREEN_TOP}, F_SilkS},
{ { LAYER_INFO::CLASS::REF_DES, LAYER_INFO::SUBCLASS::ASSEMBLY_BOTTOM}, B_Fab},
{ { LAYER_INFO::CLASS::REF_DES, LAYER_INFO::SUBCLASS::ASSEMBLY_TOP}, F_Fab},
{ { LAYER_INFO::CLASS::MANUFACTURING, LAYER_INFO::SUBCLASS::MFR_AUTOSILK_BOTTOM}, B_SilkS},
{ { LAYER_INFO::CLASS::MANUFACTURING, LAYER_INFO::SUBCLASS::MFR_AUTOSILK_TOP}, F_SilkS},
}
@ F_CrtYd
Definition layer_ids.h:116
@ F_Fab
Definition layer_ids.h:119
@ F_SilkS
Definition layer_ids.h:100
@ B_CrtYd
Definition layer_ids.h:115
@ B_SilkS
Definition layer_ids.h:101
@ B_Fab
Definition layer_ids.h:118

Map of the pre-set class:subclass pairs to standard layers.

Allegro doesn't really have a neat mapping onto KiCad layers. In theory, we could use the Films to map things that actually end up on the silkscreen layer (films can pick things out by class:subclass), but that would be quite fiddly and would fail if the films weren't configured right.

Definition at line 233 of file allegro_builder.cpp.

Referenced by ALLEGRO::LAYER_MAPPER::FinalizeLayers(), and ALLEGRO::LAYER_MAPPER::GetLayer().

◆ s_OptionalFixedMappings

const std::unordered_map<LAYER_INFO, wxString> s_OptionalFixedMappings
static
Initial value:
= {
{ { LAYER_INFO::CLASS::PACKAGE_GEOMETRY, LAYER_INFO::SUBCLASS::DFA_BOUND_TOP}, "DFA_BOUND_TOP" },
{ { LAYER_INFO::CLASS::PACKAGE_GEOMETRY, LAYER_INFO::SUBCLASS::PGEOM_DISPLAY_TOP}, "DISPLAY_TOP" },
{ { LAYER_INFO::CLASS::PACKAGE_GEOMETRY, LAYER_INFO::SUBCLASS::PGEOM_DISPLAY_BOTTOM}, "DISPLAY_BOTTOM" },
{ { LAYER_INFO::CLASS::PACKAGE_GEOMETRY, LAYER_INFO::SUBCLASS::PGEOM_BODY_CENTER}, "BODY_CENTER" },
{ { LAYER_INFO::CLASS::BOARD_GEOMETRY, LAYER_INFO::SUBCLASS::BGEOM_DIMENSION}, "DIMENSION" },
{ { LAYER_INFO::CLASS::DRAWING_FORMAT, LAYER_INFO::SUBCLASS::DFMT_OUTLINE}, "PAGE_OUTLINE" },
{ { LAYER_INFO::CLASS::COMPONENT_VALUE, LAYER_INFO::SUBCLASS::DISPLAY_BOTTOM}, "DISPLAY_BOTTOM" },
{ { LAYER_INFO::CLASS::COMPONENT_VALUE, LAYER_INFO::SUBCLASS::DISPLAY_TOP}, "DISPLAY_TOP" },
{ { LAYER_INFO::CLASS::COMPONENT_VALUE, LAYER_INFO::SUBCLASS::SILKSCREEN_BOTTOM}, "COMPVAL_TYPE_BOTTOM"},
{ { LAYER_INFO::CLASS::COMPONENT_VALUE, LAYER_INFO::SUBCLASS::SILKSCREEN_TOP}, "COMPVAL_TYPE_TOP"},
{ { LAYER_INFO::CLASS::DEVICE_TYPE, LAYER_INFO::SUBCLASS::DISPLAY_BOTTOM}, "DISPLAY_BOTTOM" },
{ { LAYER_INFO::CLASS::DEVICE_TYPE, LAYER_INFO::SUBCLASS::DISPLAY_TOP}, "DISPLAY_TOP" },
{ { LAYER_INFO::CLASS::DEVICE_TYPE, LAYER_INFO::SUBCLASS::SILKSCREEN_BOTTOM}, "DEVICE_TYPE_BOTTOM"},
{ { LAYER_INFO::CLASS::DEVICE_TYPE, LAYER_INFO::SUBCLASS::SILKSCREEN_TOP}, "DEVICE_TYPE_TOP"},
{ { LAYER_INFO::CLASS::TOLERANCE, LAYER_INFO::SUBCLASS::DISPLAY_BOTTOM}, "DISPLAY_BOTTOM" },
{ { LAYER_INFO::CLASS::TOLERANCE, LAYER_INFO::SUBCLASS::DISPLAY_TOP}, "DISPLAY_TOP" },
{ { LAYER_INFO::CLASS::TOLERANCE, LAYER_INFO::SUBCLASS::SILKSCREEN_BOTTOM}, "TOLERANCE_BOTTOM"},
{ { LAYER_INFO::CLASS::TOLERANCE, LAYER_INFO::SUBCLASS::SILKSCREEN_TOP}, "TOLERANCE_TOP"},
{ { LAYER_INFO::CLASS::USER_PART_NUMBER, LAYER_INFO::SUBCLASS::DISPLAY_BOTTOM}, "DISPLAY_BOTTOM" },
{ { LAYER_INFO::CLASS::USER_PART_NUMBER, LAYER_INFO::SUBCLASS::DISPLAY_TOP}, "DISPLAY_TOP" },
{ { LAYER_INFO::CLASS::USER_PART_NUMBER, LAYER_INFO::SUBCLASS::SILKSCREEN_BOTTOM}, "USER_PART_NUM_BOTTOM"},
{ { LAYER_INFO::CLASS::USER_PART_NUMBER, LAYER_INFO::SUBCLASS::SILKSCREEN_TOP}, "USER_PART_NUM_TOP"},
}

Names for custom KiCad layers that correspond to pre-defined Allegro layers.

Multiple class:subclasses can share a layer name, in which case, they will share a layer.

This is a balance between running out of layers and dumping too much unrelated stuff on the same layer.

Definition at line 264 of file allegro_builder.cpp.

Referenced by ALLEGRO::LAYER_MAPPER::GetLayer().

◆ traceAllegroPerf

const wxChar* const traceAllegroPerf = wxT( "KICAD_ALLEGRO_PERF" )
static

Definition at line 63 of file allegro_builder.cpp.