diff options
author | jaseg <git@jaseg.de> | 2021-01-30 14:17:42 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2021-01-30 14:17:42 +0100 |
commit | a6540b73dabc3af766643657b226f942ef05656c (patch) | |
tree | 9d2ae518ddb23493efc4bfdba16fb1982602646d /src/out_sexp.cpp | |
parent | eac89409b80c8f61efc98a20b4d742c878cde637 (diff) | |
download | gerbolyze-a6540b73dabc3af766643657b226f942ef05656c.tar.gz gerbolyze-a6540b73dabc3af766643657b226f942ef05656c.tar.bz2 gerbolyze-a6540b73dabc3af766643657b226f942ef05656c.zip |
Multi-layer module export working
Diffstat (limited to 'src/out_sexp.cpp')
-rw-r--r-- | src/out_sexp.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/out_sexp.cpp b/src/out_sexp.cpp index 90adef2..9a04416 100644 --- a/src/out_sexp.cpp +++ b/src/out_sexp.cpp @@ -32,7 +32,8 @@ using namespace std; KicadSexpOutput::KicadSexpOutput(ostream &out, string mod_name, string layer, bool only_polys, string ref_text, string val_text, d2p ref_pos, d2p val_pos) : StreamPolygonSink(out, only_polys), m_mod_name(mod_name), - m_layer(layer), + m_layer(layer == "auto" ? "unknown" : layer), + m_auto_layer(layer == "auto"), m_val_text(val_text), m_ref_pos(ref_pos), m_val_pos(val_pos) @@ -63,7 +64,28 @@ KicadSexpOutput &KicadSexpOutput::operator<<(GerberPolarityToken pol) { return *this; } +KicadSexpOutput &KicadSexpOutput::operator<<(const LayerNameToken &layer_name) { + if (!m_auto_layer) + return *this; + + cerr << "Setting S-Exp export layer to \"" << layer_name.m_name << "\"" << endl; + if (!layer_name.m_name.empty()) { + m_layer = layer_name.m_name; + } else { + m_layer = "unknown"; + } + + return *this; +} + KicadSexpOutput &KicadSexpOutput::operator<<(const Polygon &poly) { + if (m_auto_layer) { + if (std::find(m_export_layers->begin(), m_export_layers->end(), m_layer) == m_export_layers->end()) { + cerr << "Rejecting S-Exp export layer \"" << m_layer << "\"" << endl; + return *this; + } + } + if (poly.size() < 3) { cerr << "Warning: " << poly.size() << "-element polygon passed to KicadSexpOutput" << endl; return *this; |