mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 23:31:59 +08:00
full config in json for upload
This commit is contained in:
parent
a30961f59a
commit
a627c4c64e
@ -1282,18 +1282,13 @@ void PrinterPickWebViewDialog::request_compatible_printers_FFF() {
|
|||||||
// filename: string;
|
// filename: string;
|
||||||
// }
|
// }
|
||||||
const Preset &selected_printer = wxGetApp().preset_bundle->printers.get_selected_preset();
|
const Preset &selected_printer = wxGetApp().preset_bundle->printers.get_selected_preset();
|
||||||
const Preset &selected_filament = wxGetApp().preset_bundle->filaments.get_selected_preset();
|
const DynamicPrintConfig full_config = wxGetApp().preset_bundle->full_config();
|
||||||
double nozzle_diameter = static_cast<const ConfigOptionFloats *>(
|
double nozzle_diameter = static_cast<const ConfigOptionFloats *>(full_config.option("nozzle_diameter"))->values[0];
|
||||||
selected_printer.config.option("nozzle_diameter")
|
|
||||||
)
|
|
||||||
->values[0];
|
|
||||||
wxString nozzle_diameter_serialized = double_to_string(nozzle_diameter);
|
wxString nozzle_diameter_serialized = double_to_string(nozzle_diameter);
|
||||||
nozzle_diameter_serialized.Replace(L",", L".");
|
nozzle_diameter_serialized.Replace(L",", L".");
|
||||||
// Sending only first filament type for now. This should change to array of values
|
// Sending only first filament type for now. This should change to array of values
|
||||||
const std::string filament_type_serialized = selected_filament.config.option("filament_type")
|
const std::string filament_type_serialized = full_config.option("filament_type")->serialize();
|
||||||
->serialize();
|
std::string printer_model_serialized = full_config.option("printer_model")->serialize();
|
||||||
std::string printer_model_serialized = selected_printer.config.option("printer_model")
|
|
||||||
->serialize();
|
|
||||||
|
|
||||||
std::string vendor_repo_prefix;
|
std::string vendor_repo_prefix;
|
||||||
if (selected_printer.vendor) {
|
if (selected_printer.vendor) {
|
||||||
@ -1312,7 +1307,6 @@ void PrinterPickWebViewDialog::request_compatible_printers_FFF() {
|
|||||||
const std::string uuid = wxGetApp().plater()->get_user_account()->get_current_printer_uuid_from_connect(printer_model_serialized);
|
const std::string uuid = wxGetApp().plater()->get_user_account()->get_current_printer_uuid_from_connect(printer_model_serialized);
|
||||||
const std::string filename = wxGetApp().plater()->get_upload_filename();
|
const std::string filename = wxGetApp().plater()->get_upload_filename();
|
||||||
//filament_abrasive
|
//filament_abrasive
|
||||||
const std::string filament_abrasive = selected_filament.config.option("filament_abrasive")->serialize();
|
|
||||||
std::string request = GUI::format(
|
std::string request = GUI::format(
|
||||||
"{"
|
"{"
|
||||||
"\"printerUuid\": \"%4%\", "
|
"\"printerUuid\": \"%4%\", "
|
||||||
@ -1320,30 +1314,15 @@ void PrinterPickWebViewDialog::request_compatible_printers_FFF() {
|
|||||||
"\"nozzleDiameter\": %2%, "
|
"\"nozzleDiameter\": %2%, "
|
||||||
"\"material\": \"%1%\", "
|
"\"material\": \"%1%\", "
|
||||||
"\"filename\": \"%5%\", "
|
"\"filename\": \"%5%\", "
|
||||||
//"\"filamentAbrasive\": \"%6%\", "
|
"\"fullConfig\": {"
|
||||||
"\"printerConfig\": {"
|
, filament_type_serialized, nozzle_diameter_serialized, printer_model_serialized, uuid, filename);
|
||||||
, filament_type_serialized, nozzle_diameter_serialized, printer_model_serialized, uuid, filename/*, filament_abrasive*/);
|
|
||||||
|
|
||||||
// std::map<t_config_option_key, std::unique_ptr<ConfigOption>>::const_iterator
|
for (auto it = full_config.cbegin(); it != full_config.cend(); ++it) {
|
||||||
for (auto it = selected_printer.config.cbegin(); it != selected_printer.config.cend(); ++it) {
|
std::string value = full_config.option(it->first)->serialize();
|
||||||
std::string value = selected_printer.config.option(it->first)->serialize();
|
boost::algorithm::replace_all(value, "\"", "\\\"");
|
||||||
if (value.find('\"') != std::string::npos) {
|
request += it == full_config.cbegin() ? "" : ",";
|
||||||
continue;
|
|
||||||
}
|
|
||||||
request += it == selected_printer.config.cbegin() ? "" : ",";
|
|
||||||
request += GUI::format("\"%1%\": \"%2%\"", it->first, value);
|
request += GUI::format("\"%1%\": \"%2%\"", it->first, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
request += "}, \"filamentConfig\": {";
|
|
||||||
for (auto it = selected_filament.config.cbegin(); it != selected_filament.config.cend(); ++it) {
|
|
||||||
std::string value = selected_filament.config.option(it->first)->serialize();
|
|
||||||
if (value.find('\"') != std::string::npos) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
request += it == selected_filament.config.cbegin() ? "" : ",";
|
|
||||||
request += GUI::format("\"%1%\": \"%2%\"", it->first, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
request += "}}";
|
request += "}}";
|
||||||
|
|
||||||
wxString script = GUI::format_wxstr("window._prusaConnect_v1.requestCompatiblePrinter(%1%)", request);
|
wxString script = GUI::format_wxstr("window._prusaConnect_v1.requestCompatiblePrinter(%1%)", request);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user