Skip to content

Commit e64598a

Browse files
authored
Merge pull request #50 from urish/enable-all-layers
Enable all available layers
2 parents d41bb50 + bab3236 commit e64598a

File tree

4 files changed

+84
-46
lines changed

4 files changed

+84
-46
lines changed

inkscape/svg2shenzhen/export.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -241,22 +241,33 @@ def __init__(self):
241241
self.bb_scaling_h = 0
242242

243243
self.layer_map = {
244-
#'inkscape-name' : kicad-name,
245-
'F.Cu' : "F.Cu",
246-
'B.Cu' : "B.Cu",
247-
# 'Adhes' : "{}.Adhes",
248-
# 'Paste' : "{}.Paste",
249-
'F.Silk' : "F.Silk",
250-
'B.Silk' : "B.Silk",
251-
'F.Mask' : "F.Mask",
252-
'B.Mask' : "B.Mask",
253-
# 'CrtYd' : "{}.CrtYd",
254-
# 'Fab' : "{}.Fab",
244+
#'inkscape-name' : 'kicad-name',
245+
'F.Cu' : 'F.Cu',
246+
'B.Cu' : 'B.Cu',
247+
'B.Adhes' : 'B.Adhes',
248+
'F.Adhes' : 'F.Adhes',
249+
'B.Paste' : 'B.Paste',
250+
'F.Paste' : 'F.Paste',
251+
'B.SilkS' : 'B.SilkS',
252+
'F.SilkS' : 'F.SilkS',
253+
'B.Mask' : 'B.Mask',
254+
'F.Mask' : 'F.Mask',
255+
'Dwgs.User' : 'Dwgs.User',
256+
'Cmts.User' : 'Cmts.User',
257+
'Eco1.User' : 'Eco1.User',
258+
'Eco2.User' : 'Eco2.User',
259+
'Margin' : 'Margin',
260+
'B.CrtYd' : 'B.CrtYd',
261+
'F.CrtYd' : 'F.CrtYd',
262+
'B.Fab' : 'B.Fab',
263+
'F.Fab' : 'F.Fab',
264+
# The following layers are here for backward compatibility:
265+
'B.Silk' : 'B.SilkS',
266+
'F.Silk' : 'F.SilkS',
255267
# 'Edge.Cuts' : "Edge.Cuts"
256268
}
257269

258270

259-
260271
def coordToKicad(self,XYCoord):
261272
return [
262273
(XYCoord[0]-self.bb_width_center)/self.bb_scaling_w,
@@ -573,7 +584,8 @@ def exportToKicad(self, png_path, output_path, layer_type, invert = "true"):
573584
else:
574585
bitmap2component_exe = os.path.join(plugin_path, 'bitmap2component.exe')
575586

576-
command = "\"%s\" \"%s\" \"%s\" %s %s %s %s" % (bitmap2component_exe, png_path, output_path, layer_type, invert , str(int(self.options.dpi)) , str(int(self.options.threshold)))
587+
layer_name = self.layer_map[layer_type]
588+
command = "\"%s\" \"%s\" \"%s\" %s %s %s %s" % (bitmap2component_exe, png_path, output_path, layer_name, invert , str(int(self.options.dpi)) , str(int(self.options.threshold)))
577589
if (self.options.debug):
578590
inkex.debug(command)
579591
return subprocess.Popen(command.encode("utf-8"), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

inkscape/svg2shenzhen/prepare.py

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,65 @@ def prepareDocument(self):
132132
rect = self.createWhitebg()
133133
white_layer.append(rect)
134134

135-
if ("Edge.Cuts" not in layers):
136-
self.createLayer("Edge.Cuts")
135+
if ("F.Cu" not in layers and "F.Cu-disabled" not in layers):
136+
self.createLayer("F.Cu")
137137

138138
if ("B.Cu-disabled" not in layers and "B.Cu" not in layers):
139139
self.createLayer("B.Cu-disabled")
140140

141-
if ("B.Mask-disabled" not in layers and "B.Mask" not in layers):
142-
self.createLayer("B.Mask-disabled")
141+
if ("B.Adhes-disabled" not in layers and "B.Adhes" not in layers):
142+
self.createLayer("B.Adhes-disabled")
143143

144-
if ("B.Silk-disabled" not in layers and "B.Silk" not in layers):
145-
self.createLayer("B.Silk-disabled")
144+
if ("F.Adhes-disabled" not in layers and "F.Adhes" not in layers):
145+
self.createLayer("F.Adhes-disabled")
146146

147-
if ("F.Cu" not in layers and "F.Cu-disabled" not in layers):
148-
self.createLayer("F.Cu")
147+
if ("B.Paste-disabled" not in layers and "B.Paste" not in layers):
148+
self.createLayer("B.Paste-disabled")
149+
150+
if ("F.Paste-disabled" not in layers and "F.Paste" not in layers):
151+
self.createLayer("F.Paste-disabled")
152+
153+
if ("B.SilkS-disabled" not in layers and "B.SilkS" not in layers):
154+
self.createLayer("B.SilkS-disabled")
155+
156+
if ("F.SilkS-disabled" not in layers and "F.SilkS" not in layers):
157+
self.createLayer("F.SilkS-disabled")
158+
159+
if ("B.Mask-disabled" not in layers and "B.Mask" not in layers):
160+
self.createLayer("B.Mask-disabled")
149161

150162
if ("F.Mask-disabled" not in layers and "F.Mask" not in layers):
151163
self.createLayer("F.Mask-disabled")
152164

153-
if ("F.Silk-disabled" not in layers and "F.Silk" not in layers):
154-
self.createLayer("F.Silk-disabled")
165+
if ("Dwgs.User-disabled" not in layers and "Dwgs.User" not in layers):
166+
self.createLayer("Dwgs.User-disabled")
167+
168+
if ("Cmts.User-disabled" not in layers and "Cmts.User" not in layers):
169+
self.createLayer("Cmts.User-disabled")
170+
171+
if ("Eco1.User-disabled" not in layers and "Eco1.User" not in layers):
172+
self.createLayer("Eco1.User-disabled")
173+
174+
if ("Eco2.User-disabled" not in layers and "Eco2.User" not in layers):
175+
self.createLayer("Eco2.User-disabled")
176+
177+
if ("Edge.Cuts" not in layers):
178+
self.createLayer("Edge.Cuts")
179+
180+
if ("Margin-disabled" not in layers and "Margin" not in layers):
181+
self.createLayer("Margin-disabled")
182+
183+
if ("B.CrtYd-disabled" not in layers and "B.CrtYd" not in layers):
184+
self.createLayer("B.CrtYd-disabled")
185+
186+
if ("F.CrtYd-disabled" not in layers and "F.CrtYd" not in layers):
187+
self.createLayer("F.CrtYd-disabled")
188+
189+
if ("B.Fab-disabled" not in layers and "B.Fab" not in layers):
190+
self.createLayer("B.Fab-disabled")
191+
192+
if ("F.Fab-disabled" not in layers and "F.Fab" not in layers):
193+
self.createLayer("F.Fab-disabled")
155194

156195
if ("Drill" not in layers):
157196
self.createLayer("Drill")

src/bitmap2component.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class BITMAPCONV_INFO
8080
* Creates the output file specified by m_Outfile,
8181
* depending on file format given by m_Format
8282
*/
83-
void CreateOutputFile( BMP2CMP_MOD_LAYER aModLayer = (BMP2CMP_MOD_LAYER) 0 );
83+
void CreateOutputFile( BMP2CMP_MOD_LAYER aModLayer = (BMP2CMP_MOD_LAYER) 0, const char * aLayerName = NULL );
8484

8585

8686
private:
@@ -134,7 +134,7 @@ BITMAPCONV_INFO::BITMAPCONV_INFO()
134134

135135
int bitmap2component( potrace_bitmap_t* aPotrace_bitmap, FILE* aOutfile,
136136
OUTPUT_FMT_ID aFormat, int aDpi_X, int aDpi_Y,
137-
BMP2CMP_MOD_LAYER aModLayer )
137+
BMP2CMP_MOD_LAYER aModLayer, const char * aLayerName = NULL )
138138
{
139139
potrace_param_t* param;
140140
potrace_state_t* st;
@@ -201,7 +201,7 @@ int bitmap2component( potrace_bitmap_t* aPotrace_bitmap, FILE* aOutfile,
201201
info.m_ScaleX = 1e6 * 25.4 / aDpi_X; // the conversion scale from PPI to UI
202202
info.m_ScaleY = 1e6 * 25.4 / aDpi_Y; // Y axis is top to bottom in modedit
203203

204-
info.CreateOutputFile( aModLayer );
204+
info.CreateOutputFile( aModLayer, aLayerName );
205205
break;
206206

207207
default:
@@ -440,7 +440,7 @@ void BITMAPCONV_INFO::OuputOnePolygon( SHAPE_LINE_CHAIN & aPolygon, const char*
440440
}
441441

442442

443-
void BITMAPCONV_INFO::CreateOutputFile( BMP2CMP_MOD_LAYER aModLayer )
443+
void BITMAPCONV_INFO::CreateOutputFile( BMP2CMP_MOD_LAYER aModLayer, const char * aLayerName )
444444
{
445445
std::vector <potrace_dpoint_t> cornersBuffer;
446446

@@ -538,7 +538,7 @@ void BITMAPCONV_INFO::CreateOutputFile( BMP2CMP_MOD_LAYER aModLayer )
538538
for( int ii = 0; ii < polyset_areas.OutlineCount(); ii++ )
539539
{
540540
SHAPE_LINE_CHAIN& poly = polyset_areas.Outline( ii );
541-
OuputOnePolygon(poly, getBrdLayerName( aModLayer ) );
541+
OuputOnePolygon(poly, aLayerName != NULL ? aLayerName : getBrdLayerName( aModLayer ) );
542542
}
543543

544544
polyset_areas.RemoveAllContours();

src/main.cpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using namespace std;
1515

1616
extern int bitmap2component( potrace_bitmap_t* aPotrace_bitmap, FILE* aOutfile,
1717
OUTPUT_FMT_ID aFormat, int aDpi_X, int aDpi_Y,
18-
BMP2CMP_MOD_LAYER aModLayer );
18+
BMP2CMP_MOD_LAYER aModLayer, const char * layer_name = NULL );
1919

2020

2121
string pcb_header = "(kicad_pcb (version 4) (host pcbnew 4.0.7)"
@@ -139,7 +139,8 @@ int main(int argc, char* argv[])
139139
string output_filename;
140140

141141

142-
BMP2CMP_MOD_LAYER kicad_output_layer;
142+
BMP2CMP_MOD_LAYER kicad_output_layer = MOD_LYR_FCU;
143+
const char * layer_name = NULL;
143144

144145
showUsage();
145146

@@ -149,21 +150,7 @@ int main(int argc, char* argv[])
149150
output_filename = string(argv[2]);
150151

151152
if (argc > 3){
152-
string layer_name = string(argv[3]);
153-
if (layer_name == "F.Cu" )
154-
kicad_output_layer = MOD_LYR_FCU;
155-
else if(layer_name == "B.Cu")
156-
kicad_output_layer = MOD_LYR_BCU;
157-
else if(layer_name == "F.Mask")
158-
kicad_output_layer = MOD_LYR_FMASK;
159-
else if(layer_name == "B.Mask")
160-
kicad_output_layer = MOD_LYR_BMASK;
161-
else if(layer_name == "F.Silk")
162-
kicad_output_layer = MOD_LYR_FSILKS;
163-
else if(layer_name == "B.Silk")
164-
kicad_output_layer = MOD_LYR_BSILKS;
165-
else
166-
kicad_output_layer = MOD_LYR_FCU;
153+
layer_name = argv[3];
167154
}
168155

169156

@@ -246,7 +233,7 @@ int main(int argc, char* argv[])
246233
printf("[bitmap2component] Trace image\n");
247234

248235
// fprintf(pFile, pcb_header.c_str());
249-
bitmap2component( potrace_bitmap, pFile, PCBNEW_KICAD_MOD, dpi, dpi, kicad_output_layer );
236+
bitmap2component( potrace_bitmap, pFile, PCBNEW_KICAD_MOD, dpi, dpi, kicad_output_layer, layer_name );
250237
// fprintf(pFile, pcb_footer.c_str());
251238

252239

0 commit comments

Comments
 (0)