diff --git a/src/layoutwriter.cpp b/src/layoutwriter.cpp index 5b06bb2..1142adb 100644 --- a/src/layoutwriter.cpp +++ b/src/layoutwriter.cpp @@ -129,6 +129,7 @@ int LayoutWriter::write(Block& block, long double const offset_x, long double co if(data.out_format==".kicad_pcb") write_kicad_pcb(block, f_out, offset_x, offset_y, name); else if(data.out_format==".kicad_mod") write_kicad_mod(block, f_out, offset_x, offset_y, name); + else if(data.out_format==".svg") write_svg(block, f_out, offset_x, offset_y, name); else if(data.out_format==".lht") write_lht(block, f_out, offset_x, offset_y, name); else if(data.out_format==".m") write_m(block, f_out, offset_x, offset_y, name); if(out_names) out_names->push_back(n_out); // Success message to stdout in GUI mode @@ -364,6 +365,46 @@ void LayoutWriter::write_kicad_mod(Block& block, ofstream& f_out, long double co f_out << ")\n"; } +//****************************************************************************** +void LayoutWriter::write_svg(Block& block, ofstream& f_out, long double const offset_x, long double const offset_y, string const& name) const { + f_out << "\n" + "\n"; + f_out << "\n"; + for(shared_ptr it : block.elements) { + if(!it->getActive()) + continue; + + string type = it->getType(); + if(type == "SUBST" || type == "MGAP" || type == "MOPEN" || type == "MSTEP") { + //nothing to do + } else if(type == "Pac") { + Pac* pac = dynamic_cast(it.get()); + f_out << " getX() + offset_x/2 << "\" y=\"" << it->getY() + offset_y << "\" width=\"" << (pac->is_size_set ? it->getW() : 0.01) << "\" height=\"" << (pac->is_size_set ? it->getL() : 0.01) << "\" fill=\"none\" stroke=\"black\"/>\n"; + } else if(type == "MCORN" || type == "MCROSS" || type == "MMBEND" || type == "MLIN" || type == "MRSTUB" || type == "MTEE") { + f_out << " getNpoint(); i++) { + f_out << (i == 0 ? "M" : "L") << it->getP(i, X, R, ABS) + offset_x/2 << " " << it->getP(i, Y, R, ABS) + offset_y << " "; + } + f_out << "Z\" fill=\"black\" stroke=\"none\"/>\n"; + } else if(type == "MCOUPLED") { + f_out << " getNpoint() / 2; i++) { + f_out << (i == 0 ? "M" : "L") << it->getP(i, X, R, ABS) + offset_x/2 << " " << it->getP(i, Y, R, ABS) + offset_y << " "; + } + f_out << "Z\" fill=\"black\" stroke=\"none\"/>\n"; + f_out << " getNpoint() / 2; i < it->getNpoint(); i++) { + f_out << (i == it->getNpoint() / 2 ? "M" : "L") << it->getP(i, X, R, ABS) + offset_x/2 << " " << it->getP(i, Y, R, ABS) + offset_y << " "; + } + f_out << "Z\" fill=\"black\" stroke=\"none\"/>\n"; + } else if(type == "MVIA") { + f_out << " getX() + offset_x/2 << "\" cy=\"" << it->getY() + offset_y << "\" r=\"" << it->getD() / 2 << "\" fill=\"black\" stroke=\"none\"/>\n"; + } + } + f_out << "\n"; + f_out << "\n"; +} + //****************************************************************************** void LayoutWriter::write_lht(Block& block, ofstream& f_out, long double const offset_x, long double const offset_y, string const& name) const { string type; diff --git a/src/layoutwriter.hpp b/src/layoutwriter.hpp index 69c6d59..1dda2bc 100644 --- a/src/layoutwriter.hpp +++ b/src/layoutwriter.hpp @@ -35,6 +35,7 @@ class LayoutWriter { //TODO array offset ? void write_kicad_pcb(Block& block, std::ofstream& f_out, long double const offset_x, long double const offset_y, std::string const& name) const; void write_kicad_mod(Block& block, std::ofstream& f_out, long double const offset_x, long double const offset_y, std::string const& name) const; + void write_svg(Block& block, std::ofstream& f_out, long double const offset_x, long double const offset_y, std::string const& name) const; void write_lht(Block& block, std::ofstream& f_out, long double const offset_x, long double const offset_y, std::string const& name) const; void write_m(Block& block, std::ofstream& f_out, long double const offset_x, long double const offset_y, std::string const& name) const; diff --git a/src/main.cpp b/src/main.cpp index 374d296..2e96369 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char* argv[]) { for(int i=1;icb_format->addItem(tr(".kicad_mod")); ui->cb_format->addItem(tr(".lht")); ui->cb_format->addItem(tr(".m")); + ui->cb_format->addItem(tr(".svg")); ui->cb_format->setCurrentText(out_format); ui->rb_export_whole->setChecked((_data.export_each_block || _data.export_each_subst) ? false : true); ui->rb_export_each_subst->setChecked((_data.export_each_subst && !_data.export_each_block) ? true : false); @@ -192,7 +193,7 @@ void MainWindow::write() { } //****************************************************************************** -void MainWindow::on_cb_format_currentIndexChanged(const QString out_format) { +void MainWindow::on_cb_format_currentTextChanged(const QString& out_format) { ui->gb_oems->setEnabled((out_format==".m") ? true : false); data.out_format=out_format.toStdString(); } diff --git a/src/mainwindow.hpp b/src/mainwindow.hpp index 24ce511..6decfd6 100644 --- a/src/mainwindow.hpp +++ b/src/mainwindow.hpp @@ -49,7 +49,7 @@ class MainWindow : public QMainWindow, public Loggable { void log(std::stringstream& in) override; private slots: - void on_cb_format_currentIndexChanged(QString const out_format); + void on_cb_format_currentTextChanged(const QString& out_format); void on_cb_specify_netlist_stateChanged(int const state); void on_cb_oems_pkg_stateChanged(int const state); void on_cb_oems_sort_metalresmesh_stateChanged(int const state); diff --git a/src/schparser.cpp b/src/schparser.cpp index cc26a66..1c2e256 100644 --- a/src/schparser.cpp +++ b/src/schparser.cpp @@ -245,7 +245,7 @@ int SchParser::check_qucsstudio(ifstream& f_sch, string& n_tmp, bool& is_qucsstu //****************************************************************************** int SchParser::generate_netlist(string const& n_sch, string const& n_net) const { - static constexpr array to_try{"qucs", "qucs-s"}; + const array to_try{"qucs", "qucs-s"}; string const args=" -n -i \""+n_sch+"\" -o \""+n_net+"\""; bool is_done=false;