aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2021-01-30 00:27:43 +0100
committerjaseg <git@jaseg.de>2021-01-30 00:27:43 +0100
commiteac89409b80c8f61efc98a20b4d742c878cde637 (patch)
tree469f2188f3930f74ee91d90f627fcedfd4420dfe /src/main.cpp
parent52dcceb87f5847dc235f5b5965f57881f327143c (diff)
downloadgerbolyze-eac89409b80c8f61efc98a20b4d742c878cde637.tar.gz
gerbolyze-eac89409b80c8f61efc98a20b4d742c878cde637.tar.bz2
gerbolyze-eac89409b80c8f61efc98a20b4d742c878cde637.zip
Add KiCAD sexp output
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 915b71f..52110b6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -46,6 +46,9 @@ int main(int argc, char **argv) {
{"flatten", {"--flatten"},
"Flatten output so it only consists of non-overlapping white polygons. This perform composition at the vector level. Potentially slow.",
0},
+ {"no_flatten", {"--no-flatten"},
+ "Disable automatic flattening for KiCAD S-Exp export",
+ 0},
{"only_groups", {"-g", "--only-groups"},
"Comma-separated list of group IDs to export.",
1},
@@ -64,6 +67,12 @@ int main(int argc, char **argv) {
{"size", {"-s", "--size"},
"Bitmap mode only: Physical size of output image in mm. Format: 12.34x56.78",
1},
+ {"sexp_mod_name", {"--sexp-mod-name"},
+ "Module name for KiCAD S-Exp output",
+ 1},
+ {"sexp_layer", {"--sexp-layer"},
+ "Layer for KiCAD S-Exp output",
+ 1},
{"preserve_aspect_ratio", {"-a", "--preserve-aspect-ratio"},
"Bitmap mode only: Preserve aspect ratio of image. Allowed values are meet, slice. Can also parse full SVG preserveAspectRatio syntax.",
1},
@@ -151,6 +160,7 @@ int main(int argc, char **argv) {
string fmt = args["ofmt"] ? args["ofmt"] : "gerber";
transform(fmt.begin(), fmt.end(), fmt.begin(), [](unsigned char c){ return std::tolower(c); }); /* c++ yeah */
+ bool force_flatten = false;
PolygonSink *sink = nullptr;
PolygonSink *flattener = nullptr;
if (fmt == "svg") {
@@ -161,6 +171,17 @@ int main(int argc, char **argv) {
} else if (fmt == "gbr" || fmt == "grb" || fmt == "gerber") {
sink = new SimpleGerberOutput(*out_f, only_polys, 4, precision);
+ } else if (fmt == "s-exp" || fmt == "sexp" || fmt == "kicad") {
+ if (!args["sexp_mod_name"] || !args["sexp_layer"]) {
+ cerr << "--sexp-mod-name and --sexp-layer must be given for sexp export" << endl;
+ argagg::fmt_ostream fmt(cerr);
+ fmt << usage.str() << argparser;
+ return EXIT_FAILURE;
+ }
+
+ sink = new KicadSexpOutput(*out_f, args["sexp_mod_name"], args["sexp_layer"], only_polys);
+ force_flatten = true;
+
} else {
cerr << "Unknown output format \"" << fmt << "\"" << endl;
argagg::fmt_ostream fmt(cerr);
@@ -168,7 +189,7 @@ int main(int argc, char **argv) {
return EXIT_FAILURE;
}
- if (args["flatten"]) {
+ if (args["flatten"] || (force_flatten && !args["no_flatten"])) {
flattener = new Flattener(*sink);
}
@@ -294,7 +315,7 @@ int main(int argc, char **argv) {
}
if (args["skip_usvg"]) {
- cerr << "skippint usvg" << endl;
+ cerr << "skipping usvg" << endl;
frob = barf;
} else {