KiCad PCB EDA Suite
Loading...
Searching...
No Matches
legacy_plugin.cpp File Reference
#include <cerrno>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <plugins/legacy/legacy_plugin.h>
#include <wx/ffile.h>
#include <wx/log.h>
#include <wx/string.h>
#include <string_utils.h>
#include <locale_io.h>
#include <macros.h>
#include <string_utf8_map.h>
#include <zones.h>
#include <board.h>
#include <board_design_settings.h>
#include <footprint.h>
#include <core/ignore.h>
#include <pad.h>
#include <pcb_track.h>
#include <pcb_text.h>
#include <zone.h>
#include <pcb_dimension.h>
#include <pcb_shape.h>
#include <pcb_target.h>
#include <pcb_plot_params.h>
#include <pcb_plot_params_parser.h>
#include <trigo.h>
#include <confirm.h>
#include <math/util.h>
#include <progress_reporter.h>
#include <boost/ptr_container/ptr_map.hpp>
#include <wx/filename.h>

Go to the source code of this file.

Classes

struct  LP_CACHE
 The footprint portion of the PLUGIN API, and only for the LEGACY_PLUGIN, so therefore is private to this implementation file, i.e. More...
 

Macros

#define FIRST_LAYER   0
 
#define FIRST_COPPER_LAYER   0
 
#define LAYER_N_BACK   0
 
#define LAYER_N_2   1
 
#define LAYER_N_3   2
 
#define LAYER_N_4   3
 
#define LAYER_N_5   4
 
#define LAYER_N_6   5
 
#define LAYER_N_7   6
 
#define LAYER_N_8   7
 
#define LAYER_N_9   8
 
#define LAYER_N_10   9
 
#define LAYER_N_11   10
 
#define LAYER_N_12   11
 
#define LAYER_N_13   12
 
#define LAYER_N_14   13
 
#define LAYER_N_15   14
 
#define LAYER_N_FRONT   15
 
#define LAST_COPPER_LAYER   LAYER_N_FRONT
 
#define FIRST_NON_COPPER_LAYER   16
 
#define ADHESIVE_N_BACK   16
 
#define ADHESIVE_N_FRONT   17
 
#define SOLDERPASTE_N_BACK   18
 
#define SOLDERPASTE_N_FRONT   19
 
#define SILKSCREEN_N_BACK   20
 
#define SILKSCREEN_N_FRONT   21
 
#define SOLDERMASK_N_BACK   22
 
#define SOLDERMASK_N_FRONT   23
 
#define DRAW_N   24
 
#define COMMENT_N   25
 
#define ECO1_N   26
 
#define ECO2_N   27
 
#define EDGE_N   28
 
#define LAST_NON_COPPER_LAYER   28
 
#define LAYER_BACK   (1 << LAYER_N_BACK)
 bit mask for copper layer More...
 
#define LAYER_2   (1 << LAYER_N_2)
 bit mask for layer 2 More...
 
#define LAYER_3   (1 << LAYER_N_3)
 bit mask for layer 3 More...
 
#define LAYER_4   (1 << LAYER_N_4)
 bit mask for layer 4 More...
 
#define LAYER_5   (1 << LAYER_N_5)
 bit mask for layer 5 More...
 
#define LAYER_6   (1 << LAYER_N_6)
 bit mask for layer 6 More...
 
#define LAYER_7   (1 << LAYER_N_7)
 bit mask for layer 7 More...
 
#define LAYER_8   (1 << LAYER_N_8)
 bit mask for layer 8 More...
 
#define LAYER_9   (1 << LAYER_N_9)
 bit mask for layer 9 More...
 
#define LAYER_10   (1 << LAYER_N_10)
 bit mask for layer 10 More...
 
#define LAYER_11   (1 << LAYER_N_11)
 bit mask for layer 11 More...
 
#define LAYER_12   (1 << LAYER_N_12)
 bit mask for layer 12 More...
 
#define LAYER_13   (1 << LAYER_N_13)
 bit mask for layer 13 More...
 
#define LAYER_14   (1 << LAYER_N_14)
 bit mask for layer 14 More...
 
#define LAYER_15   (1 << LAYER_N_15)
 bit mask for layer 15 More...
 
#define LAYER_FRONT   (1 << LAYER_N_FRONT)
 bit mask for component layer More...
 
#define ADHESIVE_LAYER_BACK   (1 << ADHESIVE_N_BACK)
 
#define ADHESIVE_LAYER_FRONT   (1 << ADHESIVE_N_FRONT)
 
#define SOLDERPASTE_LAYER_BACK   (1 << SOLDERPASTE_N_BACK)
 
#define SOLDERPASTE_LAYER_FRONT   (1 << SOLDERPASTE_N_FRONT)
 
#define SILKSCREEN_LAYER_BACK   (1 << SILKSCREEN_N_BACK)
 
#define SILKSCREEN_LAYER_FRONT   (1 << SILKSCREEN_N_FRONT)
 
#define SOLDERMASK_LAYER_BACK   (1 << SOLDERMASK_N_BACK)
 
#define SOLDERMASK_LAYER_FRONT   (1 << SOLDERMASK_N_FRONT)
 
#define DRAW_LAYER   (1 << DRAW_N)
 
#define COMMENT_LAYER   (1 << COMMENT_N)
 
#define ECO1_LAYER   (1 << ECO1_N)
 
#define ECO2_LAYER   (1 << ECO2_N)
 
#define EDGE_LAYER   (1 << EDGE_N)
 
#define ALL_NO_CU_LAYERS   0x1FFF0000
 
#define ALL_CU_LAYERS   0x0000FFFF
 
#define FRONT_TECH_LAYERS
 
#define BACK_TECH_LAYERS
 
#define ALL_TECH_LAYERS   (FRONT_TECH_LAYERS | BACK_TECH_LAYERS)
 
#define BACK_LAYERS   (LAYER_BACK | BACK_TECH_LAYERS)
 
#define FRONT_LAYERS   (LAYER_FRONT | FRONT_TECH_LAYERS)
 
#define ALL_USER_LAYERS   (DRAW_LAYER | COMMENT_LAYER | ECO1_LAYER | ECO2_LAYER )
 
#define NO_LAYERS   0x00000000
 
#define PCB_LEGACY_INTERNAL_UNIT   10000
 
#define SZ(x)   (sizeof(x)-1)
 Get the length of a string constant, at compile time. More...
 
#define MASK(x)   (1<<(x))
 
#define TESTLINE(x)   ( !strncasecmp( line, x, SZ( x ) ) && isSpace( line[SZ( x )] ) )
 C string compare test for a specific length of characters. More...
 
#define TESTSUBSTR(x)   ( !strncasecmp( line, x, SZ( x ) ) )
 C sub-string compare test for a specific length of characters. More...
 
#define READLINE(rdr)   rdr->ReadLine()
 

Typedefs

typedef LEGACY_PLUGIN::BIU BIU
 
typedef unsigned LEG_MASK
 
typedef unsigned LAYER_MSK
 
typedef boost::ptr_map< std::string, FOOTPRINTFOOTPRINT_MAP
 

Functions

static bool isSpace (int c)
 
static GR_TEXT_H_ALIGN_T horizJustify (const char *horizontal)
 
static GR_TEXT_V_ALIGN_T vertJustify (const char *vertical)
 
int layerMaskCountSet (LEG_MASK aMask)
 Count the number of set layers in the mask. More...
 
bool is_leg_copperlayer_valid (int aCu_Count, int aLegacyLayerNum)
 
static int intParse (const char *next, const char **out=nullptr)
 Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointer at out if it is not NULL, just like "man strtol()". More...
 
static long hexParse (const char *next, const char **out=nullptr)
 Parse an ASCII hex integer string with possible leading whitespace into a long integer and updates the pointer at out if it is not nullptr, just like "man strtol". More...
 

Variables

static const char delims [] = " \t\r\n"
 

Macro Definition Documentation

◆ ADHESIVE_LAYER_BACK

#define ADHESIVE_LAYER_BACK   (1 << ADHESIVE_N_BACK)

Definition at line 152 of file legacy_plugin.cpp.

◆ ADHESIVE_LAYER_FRONT

#define ADHESIVE_LAYER_FRONT   (1 << ADHESIVE_N_FRONT)

Definition at line 153 of file legacy_plugin.cpp.

◆ ADHESIVE_N_BACK

#define ADHESIVE_N_BACK   16

Definition at line 119 of file legacy_plugin.cpp.

◆ ADHESIVE_N_FRONT

#define ADHESIVE_N_FRONT   17

Definition at line 120 of file legacy_plugin.cpp.

◆ ALL_CU_LAYERS

#define ALL_CU_LAYERS   0x0000FFFF

Definition at line 170 of file legacy_plugin.cpp.

◆ ALL_NO_CU_LAYERS

#define ALL_NO_CU_LAYERS   0x1FFF0000

Definition at line 169 of file legacy_plugin.cpp.

◆ ALL_TECH_LAYERS

#define ALL_TECH_LAYERS   (FRONT_TECH_LAYERS | BACK_TECH_LAYERS)

Definition at line 175 of file legacy_plugin.cpp.

◆ ALL_USER_LAYERS

#define ALL_USER_LAYERS   (DRAW_LAYER | COMMENT_LAYER | ECO1_LAYER | ECO2_LAYER )

Definition at line 179 of file legacy_plugin.cpp.

◆ BACK_LAYERS

#define BACK_LAYERS   (LAYER_BACK | BACK_TECH_LAYERS)

Definition at line 176 of file legacy_plugin.cpp.

◆ BACK_TECH_LAYERS

#define BACK_TECH_LAYERS
Value:
#define ADHESIVE_LAYER_BACK
#define SOLDERPASTE_LAYER_BACK
#define SILKSCREEN_LAYER_BACK
#define SOLDERMASK_LAYER_BACK

Definition at line 173 of file legacy_plugin.cpp.

◆ COMMENT_LAYER

#define COMMENT_LAYER   (1 << COMMENT_N)

Definition at line 161 of file legacy_plugin.cpp.

◆ COMMENT_N

#define COMMENT_N   25

Definition at line 128 of file legacy_plugin.cpp.

◆ DRAW_LAYER

#define DRAW_LAYER   (1 << DRAW_N)

Definition at line 160 of file legacy_plugin.cpp.

◆ DRAW_N

#define DRAW_N   24

Definition at line 127 of file legacy_plugin.cpp.

◆ ECO1_LAYER

#define ECO1_LAYER   (1 << ECO1_N)

Definition at line 162 of file legacy_plugin.cpp.

◆ ECO1_N

#define ECO1_N   26

Definition at line 129 of file legacy_plugin.cpp.

◆ ECO2_LAYER

#define ECO2_LAYER   (1 << ECO2_N)

Definition at line 163 of file legacy_plugin.cpp.

◆ ECO2_N

#define ECO2_N   27

Definition at line 130 of file legacy_plugin.cpp.

◆ EDGE_LAYER

#define EDGE_LAYER   (1 << EDGE_N)

Definition at line 164 of file legacy_plugin.cpp.

◆ EDGE_N

#define EDGE_N   28

Definition at line 131 of file legacy_plugin.cpp.

◆ FIRST_COPPER_LAYER

#define FIRST_COPPER_LAYER   0

Definition at line 99 of file legacy_plugin.cpp.

◆ FIRST_LAYER

#define FIRST_LAYER   0

Definition at line 98 of file legacy_plugin.cpp.

◆ FIRST_NON_COPPER_LAYER

#define FIRST_NON_COPPER_LAYER   16

Definition at line 118 of file legacy_plugin.cpp.

◆ FRONT_LAYERS

#define FRONT_LAYERS   (LAYER_FRONT | FRONT_TECH_LAYERS)

Definition at line 177 of file legacy_plugin.cpp.

◆ FRONT_TECH_LAYERS

#define FRONT_TECH_LAYERS
Value:
#define SOLDERMASK_LAYER_FRONT
#define SOLDERPASTE_LAYER_FRONT
#define ADHESIVE_LAYER_FRONT
#define SILKSCREEN_LAYER_FRONT

Definition at line 171 of file legacy_plugin.cpp.

◆ LAST_COPPER_LAYER

#define LAST_COPPER_LAYER   LAYER_N_FRONT

Definition at line 116 of file legacy_plugin.cpp.

◆ LAST_NON_COPPER_LAYER

#define LAST_NON_COPPER_LAYER   28

Definition at line 132 of file legacy_plugin.cpp.

◆ LAYER_10

#define LAYER_10   (1 << LAYER_N_10)

bit mask for layer 10

Definition at line 145 of file legacy_plugin.cpp.

◆ LAYER_11

#define LAYER_11   (1 << LAYER_N_11)

bit mask for layer 11

Definition at line 146 of file legacy_plugin.cpp.

◆ LAYER_12

#define LAYER_12   (1 << LAYER_N_12)

bit mask for layer 12

Definition at line 147 of file legacy_plugin.cpp.

◆ LAYER_13

#define LAYER_13   (1 << LAYER_N_13)

bit mask for layer 13

Definition at line 148 of file legacy_plugin.cpp.

◆ LAYER_14

#define LAYER_14   (1 << LAYER_N_14)

bit mask for layer 14

Definition at line 149 of file legacy_plugin.cpp.

◆ LAYER_15

#define LAYER_15   (1 << LAYER_N_15)

bit mask for layer 15

Definition at line 150 of file legacy_plugin.cpp.

◆ LAYER_2

#define LAYER_2   (1 << LAYER_N_2)

bit mask for layer 2

Definition at line 137 of file legacy_plugin.cpp.

◆ LAYER_3

#define LAYER_3   (1 << LAYER_N_3)

bit mask for layer 3

Definition at line 138 of file legacy_plugin.cpp.

◆ LAYER_4

#define LAYER_4   (1 << LAYER_N_4)

bit mask for layer 4

Definition at line 139 of file legacy_plugin.cpp.

◆ LAYER_5

#define LAYER_5   (1 << LAYER_N_5)

bit mask for layer 5

Definition at line 140 of file legacy_plugin.cpp.

◆ LAYER_6

#define LAYER_6   (1 << LAYER_N_6)

bit mask for layer 6

Definition at line 141 of file legacy_plugin.cpp.

◆ LAYER_7

#define LAYER_7   (1 << LAYER_N_7)

bit mask for layer 7

Definition at line 142 of file legacy_plugin.cpp.

◆ LAYER_8

#define LAYER_8   (1 << LAYER_N_8)

bit mask for layer 8

Definition at line 143 of file legacy_plugin.cpp.

◆ LAYER_9

#define LAYER_9   (1 << LAYER_N_9)

bit mask for layer 9

Definition at line 144 of file legacy_plugin.cpp.

◆ LAYER_BACK

#define LAYER_BACK   (1 << LAYER_N_BACK)

bit mask for copper layer

Definition at line 136 of file legacy_plugin.cpp.

◆ LAYER_FRONT

#define LAYER_FRONT   (1 << LAYER_N_FRONT)

bit mask for component layer

Definition at line 151 of file legacy_plugin.cpp.

◆ LAYER_N_10

#define LAYER_N_10   9

Definition at line 109 of file legacy_plugin.cpp.

◆ LAYER_N_11

#define LAYER_N_11   10

Definition at line 110 of file legacy_plugin.cpp.

◆ LAYER_N_12

#define LAYER_N_12   11

Definition at line 111 of file legacy_plugin.cpp.

◆ LAYER_N_13

#define LAYER_N_13   12

Definition at line 112 of file legacy_plugin.cpp.

◆ LAYER_N_14

#define LAYER_N_14   13

Definition at line 113 of file legacy_plugin.cpp.

◆ LAYER_N_15

#define LAYER_N_15   14

Definition at line 114 of file legacy_plugin.cpp.

◆ LAYER_N_2

#define LAYER_N_2   1

Definition at line 101 of file legacy_plugin.cpp.

◆ LAYER_N_3

#define LAYER_N_3   2

Definition at line 102 of file legacy_plugin.cpp.

◆ LAYER_N_4

#define LAYER_N_4   3

Definition at line 103 of file legacy_plugin.cpp.

◆ LAYER_N_5

#define LAYER_N_5   4

Definition at line 104 of file legacy_plugin.cpp.

◆ LAYER_N_6

#define LAYER_N_6   5

Definition at line 105 of file legacy_plugin.cpp.

◆ LAYER_N_7

#define LAYER_N_7   6

Definition at line 106 of file legacy_plugin.cpp.

◆ LAYER_N_8

#define LAYER_N_8   7

Definition at line 107 of file legacy_plugin.cpp.

◆ LAYER_N_9

#define LAYER_N_9   8

Definition at line 108 of file legacy_plugin.cpp.

◆ LAYER_N_BACK

#define LAYER_N_BACK   0

Definition at line 100 of file legacy_plugin.cpp.

◆ LAYER_N_FRONT

#define LAYER_N_FRONT   15

Definition at line 115 of file legacy_plugin.cpp.

◆ MASK

#define MASK (   x)    (1<<(x))

Definition at line 196 of file legacy_plugin.cpp.

◆ NO_LAYERS

#define NO_LAYERS   0x00000000

Definition at line 181 of file legacy_plugin.cpp.

◆ PCB_LEGACY_INTERNAL_UNIT

#define PCB_LEGACY_INTERNAL_UNIT   10000

Definition at line 185 of file legacy_plugin.cpp.

◆ READLINE

#define READLINE (   rdr)    rdr->ReadLine()

Definition at line 231 of file legacy_plugin.cpp.

◆ SILKSCREEN_LAYER_BACK

#define SILKSCREEN_LAYER_BACK   (1 << SILKSCREEN_N_BACK)

Definition at line 156 of file legacy_plugin.cpp.

◆ SILKSCREEN_LAYER_FRONT

#define SILKSCREEN_LAYER_FRONT   (1 << SILKSCREEN_N_FRONT)

Definition at line 157 of file legacy_plugin.cpp.

◆ SILKSCREEN_N_BACK

#define SILKSCREEN_N_BACK   20

Definition at line 123 of file legacy_plugin.cpp.

◆ SILKSCREEN_N_FRONT

#define SILKSCREEN_N_FRONT   21

Definition at line 124 of file legacy_plugin.cpp.

◆ SOLDERMASK_LAYER_BACK

#define SOLDERMASK_LAYER_BACK   (1 << SOLDERMASK_N_BACK)

Definition at line 158 of file legacy_plugin.cpp.

◆ SOLDERMASK_LAYER_FRONT

#define SOLDERMASK_LAYER_FRONT   (1 << SOLDERMASK_N_FRONT)

Definition at line 159 of file legacy_plugin.cpp.

◆ SOLDERMASK_N_BACK

#define SOLDERMASK_N_BACK   22

Definition at line 125 of file legacy_plugin.cpp.

◆ SOLDERMASK_N_FRONT

#define SOLDERMASK_N_FRONT   23

Definition at line 126 of file legacy_plugin.cpp.

◆ SOLDERPASTE_LAYER_BACK

#define SOLDERPASTE_LAYER_BACK   (1 << SOLDERPASTE_N_BACK)

Definition at line 154 of file legacy_plugin.cpp.

◆ SOLDERPASTE_LAYER_FRONT

#define SOLDERPASTE_LAYER_FRONT   (1 << SOLDERPASTE_N_FRONT)

Definition at line 155 of file legacy_plugin.cpp.

◆ SOLDERPASTE_N_BACK

#define SOLDERPASTE_N_BACK   18

Definition at line 121 of file legacy_plugin.cpp.

◆ SOLDERPASTE_N_FRONT

#define SOLDERPASTE_N_FRONT   19

Definition at line 122 of file legacy_plugin.cpp.

◆ SZ

#define SZ (   x)    (sizeof(x)-1)

Get the length of a string constant, at compile time.

Definition at line 188 of file legacy_plugin.cpp.

◆ TESTLINE

#define TESTLINE (   x)    ( !strncasecmp( line, x, SZ( x ) ) && isSpace( line[SZ( x )] ) )

C string compare test for a specific length of characters.

Definition at line 224 of file legacy_plugin.cpp.

◆ TESTSUBSTR

#define TESTSUBSTR (   x)    ( !strncasecmp( line, x, SZ( x ) ) )

C sub-string compare test for a specific length of characters.

Definition at line 227 of file legacy_plugin.cpp.

Typedef Documentation

◆ BIU

Definition at line 93 of file legacy_plugin.cpp.

◆ FOOTPRINT_MAP

typedef boost::ptr_map< std::string, FOOTPRINT > FOOTPRINT_MAP

Definition at line 2890 of file legacy_plugin.cpp.

◆ LAYER_MSK

typedef unsigned LAYER_MSK

Definition at line 135 of file legacy_plugin.cpp.

◆ LEG_MASK

typedef unsigned LEG_MASK

Definition at line 96 of file legacy_plugin.cpp.

Function Documentation

◆ hexParse()

static long hexParse ( const char *  next,
const char **  out = nullptr 
)
inlinestatic

Parse an ASCII hex integer string with possible leading whitespace into a long integer and updates the pointer at out if it is not nullptr, just like "man strtol".

I can use this without casting, and its name says what I am doing.

Definition at line 398 of file legacy_plugin.cpp.

References next().

Referenced by LEGACY_PLUGIN::loadFOOTPRINT(), LEGACY_PLUGIN::loadGENERAL(), LEGACY_PLUGIN::loadPAD(), LEGACY_PLUGIN::loadPCB_LINE(), and LEGACY_PLUGIN::loadSETUP().

◆ horizJustify()

static GR_TEXT_H_ALIGN_T horizJustify ( const char *  horizontal)
static

◆ intParse()

static int intParse ( const char *  next,
const char **  out = nullptr 
)
inlinestatic

Parse an ASCII integer string with possible leading whitespace into an integer and updates the pointer at out if it is not NULL, just like "man strtol()".

I can use this without casting, and its name says what I am doing.

Definition at line 385 of file legacy_plugin.cpp.

References next().

Referenced by LEGACY_PLUGIN::loadDIMENSION(), LEGACY_PLUGIN::loadFOOTPRINT(), LEGACY_PLUGIN::loadFP_SHAPE(), LEGACY_PLUGIN::loadGENERAL(), LEGACY_PLUGIN::loadMODULE_TEXT(), LEGACY_PLUGIN::loadNETINFO_ITEM(), LEGACY_PLUGIN::loadPAD(), LEGACY_PLUGIN::loadPCB_LINE(), LEGACY_PLUGIN::loadPCB_TARGET(), LEGACY_PLUGIN::loadPCB_TEXT(), LEGACY_PLUGIN::loadSETUP(), LEGACY_PLUGIN::loadSHEET(), LEGACY_PLUGIN::loadTrackList(), and LEGACY_PLUGIN::loadZONE_CONTAINER().

◆ is_leg_copperlayer_valid()

bool is_leg_copperlayer_valid ( int  aCu_Count,
int  aLegacyLayerNum 
)
inline

Definition at line 296 of file legacy_plugin.cpp.

References LAYER_N_FRONT.

Referenced by LEGACY_PLUGIN::loadPCB_TEXT(), and LEGACY_PLUGIN::loadTrackList().

◆ isSpace()

static bool isSpace ( int  c)
inlinestatic

Definition at line 194 of file legacy_plugin.cpp.

References delims.

◆ layerMaskCountSet()

int layerMaskCountSet ( LEG_MASK  aMask)
inline

Count the number of set layers in the mask.

Definition at line 280 of file legacy_plugin.cpp.

Referenced by LEGACY_PLUGIN::loadGENERAL().

◆ vertJustify()

static GR_TEXT_V_ALIGN_T vertJustify ( const char *  vertical)
static

Variable Documentation

◆ delims

const char delims[] = " \t\r\n"
static

Definition at line 191 of file legacy_plugin.cpp.

Referenced by isSpace(), and LP_CACHE::ReadAndVerifyHeader().