Merge branch 'tm_sla_full_config'
This commit is contained in:
commit
6945a20e9a
2 changed files with 42 additions and 8 deletions
|
@ -1,3 +1,5 @@
|
|||
#include <string_view>
|
||||
|
||||
#include <libslic3r/SLA/RasterWriter.hpp>
|
||||
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
@ -12,14 +14,16 @@
|
|||
|
||||
namespace Slic3r { namespace sla {
|
||||
|
||||
std::string RasterWriter::createIniContent(const std::string& projectname) const
|
||||
void RasterWriter::write_ini(const std::map<std::string, std::string> &m, std::string &ini)
|
||||
{
|
||||
for (auto ¶m : m) ini += param.first + " = " + param.second + "\n";
|
||||
}
|
||||
|
||||
std::string RasterWriter::create_ini_content(const std::string& projectname) const
|
||||
{
|
||||
std::string out("action = print\njobDir = ");
|
||||
out += projectname + "\n";
|
||||
|
||||
for (auto ¶m : m_config)
|
||||
out += param.first + " = " + param.second + "\n";
|
||||
|
||||
write_ini(m_config, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -53,7 +57,12 @@ void RasterWriter::save(Zipper &zipper, const std::string &prjname)
|
|||
|
||||
zipper.add_entry("config.ini");
|
||||
|
||||
zipper << createIniContent(project);
|
||||
zipper << create_ini_content(project);
|
||||
|
||||
zipper.add_entry("prusaslicer.ini");
|
||||
std::string prusaslicer_ini;
|
||||
write_ini(m_slicer_config, prusaslicer_ini);
|
||||
zipper << prusaslicer_ini;
|
||||
|
||||
for(unsigned i = 0; i < m_layers_rst.size(); i++)
|
||||
{
|
||||
|
@ -89,6 +98,29 @@ std::string get_cfg_value(const DynamicPrintConfig &cfg, const std::string &key)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void append_full_config(const DynamicPrintConfig &cfg, std::map<std::string, std::string> &keys)
|
||||
{
|
||||
using namespace std::literals::string_view_literals;
|
||||
|
||||
// Sorted list of config keys, which shall not be stored into the ini.
|
||||
static constexpr auto banned_keys = {
|
||||
"compatible_printers"sv,
|
||||
"compatible_prints"sv,
|
||||
"print_host"sv,
|
||||
"printhost_apikey"sv,
|
||||
"printhost_cafile"sv
|
||||
};
|
||||
|
||||
assert(std::is_sorted(banned_keys.begin(), banned_keys.end()));
|
||||
auto is_banned = [](const std::string &key) {
|
||||
return std::binary_search(banned_keys.begin(), banned_keys.end(), key);
|
||||
};
|
||||
|
||||
for (const std::string &key : cfg.keys())
|
||||
if (! is_banned(key) && ! cfg.option(key)->is_nil())
|
||||
keys[key] = cfg.opt_serialize(key);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void RasterWriter::set_config(const DynamicPrintConfig &cfg)
|
||||
|
@ -101,9 +133,9 @@ void RasterWriter::set_config(const DynamicPrintConfig &cfg)
|
|||
m_config["printerVariant"] = get_cfg_value(cfg, "printer_variant");
|
||||
m_config["printerProfile"] = get_cfg_value(cfg, "printer_settings_id");
|
||||
m_config["printProfile"] = get_cfg_value(cfg, "sla_print_settings_id");
|
||||
|
||||
m_config["fileCreationTimestamp"] = Utils::utc_timestamp();
|
||||
m_config["prusaSlicerVersion"] = SLIC3R_BUILD_ID;
|
||||
append_full_config(cfg, m_slicer_config);
|
||||
}
|
||||
|
||||
void RasterWriter::set_statistics(const PrintStatistics &stats)
|
||||
|
|
|
@ -66,8 +66,10 @@ private:
|
|||
double m_gamma;
|
||||
|
||||
std::map<std::string, std::string> m_config;
|
||||
std::map<std::string, std::string> m_slicer_config;
|
||||
|
||||
std::string createIniContent(const std::string& projectname) const;
|
||||
static void write_ini(const std::map<std::string, std::string> &m, std::string &ini);
|
||||
std::string create_ini_content(const std::string& projectname) const;
|
||||
|
||||
public:
|
||||
|
||||
|
|
Loading…
Reference in a new issue