mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-02 17:10:37 +08:00
SPE-2461: GCode add more info to be used in connect/slicer analytics: introduced profile_vendor, profile_version in slicer block (bgcode) or preset parameters dump (ascii gcode) + added "Produced on" key in file block (bgcode)
This commit is contained in:
parent
0c4aab4b5a
commit
e5e8f940db
@ -46,6 +46,7 @@
|
|||||||
#include "libslic3r.h"
|
#include "libslic3r.h"
|
||||||
#include "LocalesUtils.hpp"
|
#include "LocalesUtils.hpp"
|
||||||
#include "format.hpp"
|
#include "format.hpp"
|
||||||
|
#include "Time.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -950,6 +951,7 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
|
|||||||
|
|
||||||
// file data
|
// file data
|
||||||
binary_data.file_metadata.raw_data.emplace_back("Producer", std::string(SLIC3R_APP_NAME) + " " + std::string(SLIC3R_VERSION));
|
binary_data.file_metadata.raw_data.emplace_back("Producer", std::string(SLIC3R_APP_NAME) + " " + std::string(SLIC3R_VERSION));
|
||||||
|
binary_data.file_metadata.raw_data.emplace_back("Produced on", Utils::utc_timestamp());
|
||||||
|
|
||||||
// config data
|
// config data
|
||||||
encode_full_config(*m_print, binary_data.slicer_metadata.raw_data);
|
encode_full_config(*m_print, binary_data.slicer_metadata.raw_data);
|
||||||
|
@ -491,6 +491,20 @@ void PrintConfigDef::init_common_params()
|
|||||||
def->cli = ConfigOptionDef::nocli;
|
def->cli = ConfigOptionDef::nocli;
|
||||||
def->set_default_value(new ConfigOptionEnum<AuthorizationType>(atKeyPassword));
|
def->set_default_value(new ConfigOptionEnum<AuthorizationType>(atKeyPassword));
|
||||||
|
|
||||||
|
def = this->add("profile_vendor", coString);
|
||||||
|
def->label = L("Profile vendor");
|
||||||
|
def->tooltip = L("Name of profile vendor");
|
||||||
|
def->mode = comAdvanced;
|
||||||
|
def->cli = ConfigOptionDef::nocli;
|
||||||
|
def->set_default_value(new ConfigOptionString(""));
|
||||||
|
|
||||||
|
def = this->add("profile_version", coString);
|
||||||
|
def->label = L("Profile version");
|
||||||
|
def->tooltip = L("Version of profile");
|
||||||
|
def->mode = comAdvanced;
|
||||||
|
def->cli = ConfigOptionDef::nocli;
|
||||||
|
def->set_default_value(new ConfigOptionString(""));
|
||||||
|
|
||||||
// temporary workaround for compatibility with older Slicer
|
// temporary workaround for compatibility with older Slicer
|
||||||
{
|
{
|
||||||
def = this->add("preset_name", coString);
|
def = this->add("preset_name", coString);
|
||||||
|
@ -2106,15 +2106,26 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
|
|||||||
|
|
||||||
const Preset &selected_printer = wxGetApp().preset_bundle->printers.get_selected_preset();
|
const Preset &selected_printer = wxGetApp().preset_bundle->printers.get_selected_preset();
|
||||||
std::string printer_model_serialized = full_config.option("printer_model")->serialize();
|
std::string printer_model_serialized = full_config.option("printer_model")->serialize();
|
||||||
|
|
||||||
|
const VendorProfile* vendor = nullptr;
|
||||||
std::string vendor_repo_prefix;
|
std::string vendor_repo_prefix;
|
||||||
if (selected_printer.vendor) {
|
if (selected_printer.vendor) {
|
||||||
vendor_repo_prefix = selected_printer.vendor->repo_prefix;
|
vendor = selected_printer.vendor;
|
||||||
|
|
||||||
} else if (std::string inherits = selected_printer.inherits(); !inherits.empty()) {
|
} else if (std::string inherits = selected_printer.inherits(); !inherits.empty()) {
|
||||||
const Preset *parent = wxGetApp().preset_bundle->printers.find_preset(inherits);
|
const Preset *parent = wxGetApp().preset_bundle->printers.find_preset(inherits);
|
||||||
if (parent && parent->vendor) {
|
if (parent && parent->vendor) {
|
||||||
vendor_repo_prefix = parent->vendor->repo_prefix;
|
vendor_repo_prefix = parent->vendor->repo_prefix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vendor) {
|
||||||
|
vendor_repo_prefix = vendor->repo_prefix;
|
||||||
|
// Passing extra info about preset vendor and version, so these can be inserted as metadata to GCode
|
||||||
|
full_config.set("profile_vendor", vendor->name, true);
|
||||||
|
full_config.set("profile_version", vendor->config_version.to_string(), true);
|
||||||
|
}
|
||||||
|
|
||||||
if (printer_model_serialized.find(vendor_repo_prefix) == 0) {
|
if (printer_model_serialized.find(vendor_repo_prefix) == 0) {
|
||||||
printer_model_serialized = printer_model_serialized.substr(vendor_repo_prefix.size());
|
printer_model_serialized = printer_model_serialized.substr(vendor_repo_prefix.size());
|
||||||
boost::trim_left(printer_model_serialized);
|
boost::trim_left(printer_model_serialized);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user