aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2021-01-30 14:17:42 +0100
committerjaseg <git@jaseg.de>2021-01-30 14:17:42 +0100
commita6540b73dabc3af766643657b226f942ef05656c (patch)
tree9d2ae518ddb23493efc4bfdba16fb1982602646d /src/main.cpp
parenteac89409b80c8f61efc98a20b4d742c878cde637 (diff)
downloadgerbolyze-a6540b73dabc3af766643657b226f942ef05656c.tar.gz
gerbolyze-a6540b73dabc3af766643657b226f942ef05656c.tar.bz2
gerbolyze-a6540b73dabc3af766643657b226f942ef05656c.zip
Multi-layer module export working
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 52110b6..45e2cfb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -71,7 +71,7 @@ int main(int argc, char **argv) {
"Module name for KiCAD S-Exp output",
1},
{"sexp_layer", {"--sexp-layer"},
- "Layer for KiCAD S-Exp output",
+ "Layer for KiCAD S-Exp output. Defaults to auto-detect layers from SVG layer/top-level group names",
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.",
@@ -160,6 +160,8 @@ 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 */
+ string sexp_layer = args["sexp_layer"] ? args["sexp_layer"].as<string>() : "auto";
+
bool force_flatten = false;
PolygonSink *sink = nullptr;
PolygonSink *flattener = nullptr;
@@ -172,14 +174,14 @@ int main(int argc, char **argv) {
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;
+ if (!args["sexp_mod_name"]) {
+ cerr << "--sexp-mod-name 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);
+ sink = new KicadSexpOutput(*out_f, args["sexp_mod_name"], sexp_layer, only_polys);
force_flatten = true;
} else {
@@ -206,6 +208,9 @@ int main(int argc, char **argv) {
id_match(args["only_groups"], sel.include);
if (args["exclude_groups"])
id_match(args["exclude_groups"], sel.exclude);
+ if (sexp_layer == "auto") {
+ sel.layers = &gerbolyze::kicad_default_layers;
+ }
string vectorizer = args["vectorizer"] ? args["vectorizer"] : "poisson-disc";
/* Check argument */
@@ -320,7 +325,7 @@ int main(int argc, char **argv) {
} else {
cerr << "calling usvg on " << barf << " and " << frob << endl;
- const char *command_line[] = {"usvg", barf.c_str(), frob.c_str(), NULL};
+ const char *command_line[] = {"usvg", "--keep-named-groups", barf.c_str(), frob.c_str(), NULL};
struct subprocess_s subprocess;
int rc = subprocess_create(command_line, subprocess_option_inherit_environment, &subprocess);
if (rc) {